Security and RDS Proxy
Encryption at rest and in transit, IAM database authentication, security groups and audit logs for RDS and Aurora, and RDS Proxy for connection pooling and faster failover.
Security for RDS and Aurora
Encryption at rest
- RDS and Aurora encrypt the storage with AWS KMS keys. Encryption covers the data, logs, automated backups, snapshots and read replicas.
- Encryption is chosen at creation of the database. It can't be switched on for a running instance.
- If the primary is not encrypted, its read replicas can't be encrypted either.
- To encrypt an existing unencrypted database: take a snapshot, copy it with encryption turned on, then restore the encrypted copy as a new database (the same method as for EBS volumes).
Encryption in transit
Every RDS and Aurora database accepts TLS connections. Clients use the AWS TLS root certificates to check they are talking to the real database. TLS can be forced with a parameter (for example rds.force_ssl for PostgreSQL).
Authentication
- Username and password, the normal way for each engine. Store the password in AWS Secrets Manager, which can rotate it automatically.
- IAM database authentication for MySQL, MariaDB and PostgreSQL: instead of a password, the app asks RDS for an authentication token signed with its IAM role. The token lasts 15 minutes. No password is stored in the app, and access is controlled with IAM policies.
Network and access
- Security groups control which sources can reach the database port (3306 for MySQL, 5432 for PostgreSQL). Allow the application's security group, not the internet.
- Put databases in private subnets with Public access off.
- No SSH into the instance, except with RDS Custom.
Audit logs
Turn on the engine's audit and error logs and publish them to CloudWatch Logs, where they can be kept longer and searched or alerted on.
RDS Proxy
Every database connection uses memory and CPU on the database. Some apps open thousands of short connections: a burst of Lambda functions, each opening its own connection, can exhaust the database's connection limit and slow it down.
RDS Proxy is a fully managed database proxy that sits between the app and the database.
- Clients connect to the proxy endpoint instead of the database.
- The proxy keeps a pool of database connections and shares them between clients. Thousands of client connections become a few dozen database connections.
- When a client can't be served at once, the proxy queues it instead of letting the database fall over.
What it provides:
- Efficiency: less stress on database CPU and RAM, fewer open connections and fewer timeouts.
- Faster failover: the proxy keeps client connections open during a failover and sends them to the new primary, cutting failover time for RDS and Aurora by up to 66%.
- Security: it can enforce IAM authentication for clients, and the proxy reads the database credentials from Secrets Manager, so they never sit in the code.
- Serverless: it scales automatically and is highly available across AZs.
- No code change for most apps: just point them at the proxy endpoint.
- Supports RDS for MySQL, PostgreSQL, MariaDB and SQL Server, and Aurora MySQL and PostgreSQL.
- Never publicly accessible: it can only be reached from inside the VPC.
Real-world examples
- A serverless API on Lambda scales to 3,000 concurrent functions during a sale. Without a proxy, the database hits its connection limit; with RDS Proxy, the functions share 100 connections.
- A healthcare app must encrypt all data. The team creates its RDS instance with KMS encryption, forces TLS, and uses IAM authentication so no database password is in the code.
- An old unencrypted database must be encrypted for an audit. The team snapshots it, copies the snapshot with encryption, and restores.
Exam tips
- "Encrypt an existing unencrypted RDS database" → snapshot, copy with encryption, restore.
- "Connect to RDS without a password, using IAM roles" → IAM database authentication (MySQL, MariaDB, PostgreSQL).
- "Rotate database credentials automatically" → Secrets Manager.
- "Lambda functions exhaust database connections", "too many connections" → RDS Proxy.
- "Reduce failover time for applications" → RDS Proxy.
- "Enforce IAM authentication to the database" → RDS Proxy (or IAM database authentication).
Common traps
- "Turn on encryption for a running RDS instance." It must be chosen at creation; use the snapshot method.
- "An encrypted read replica of an unencrypted primary." Not possible.
- "Make RDS Proxy public so on-premises clients can use it." The proxy is only reachable from inside the VPC (or a connected network).
- "Use IAM policies to grant SQL permissions on tables." IAM authenticates the connection; table permissions are still granted inside the database.
Hands-on lab: put RDS Proxy in front of a database
Goal: create an RDS Proxy for a small database and connect through it.
Costs money
RDS Proxy is billed per vCPU of the database (for small instances, a minimum of 2 vCPUs): about $0.03 an hour, plus the db.t4g.micro (about $0.02) and a Secrets Manager secret ($0.40 a month, prorated). Delete everything within the hour. Any Region works.
Before you start: create saa-db as in the RDS lab, but under Credentials management choose Managed in AWS Secrets Manager.
Create the proxy
RDS → Proxies → Create proxy. Engine family PostgreSQL, identifier saa-proxy, target saa-db. Under Authentication, choose the Secrets Manager secret RDS created for saa-db. Keep IAM authentication: Not required for this test. Use the same subnets and the ec2-rds-* security group that lets saa-web in. Create; it takes a few minutes.
Connect through the proxy
Copy the proxy endpoint (saa-proxy.proxy-…). From saa-web:
psql -h <proxy-endpoint> -U postgres -c "select inet_server_addr();"Use the password from the secret (Secrets Manager → the secret → Retrieve secret value). The query works through the proxy.
Watch the connections
Open saa-proxy → Monitoring. ClientConnections and DatabaseConnections show how client connections map to pooled database connections.
Expected result: the app reaches the database through the proxy without any change except the endpoint.
Clean up: delete saa-proxy, then saa-db (no final snapshot, no retained backups). Deleting the instance schedules its managed secret for deletion. Delete the rds-ec2-* and ec2-rds-* security groups.
AWS documentation
Backups, restore and cloning
Automated backups and point-in-time restore for RDS and Aurora, manual snapshots, restoring from S3, and fast Aurora clones with copy-on-write.
Amazon ElastiCache
Managed in-memory caches with Valkey, Redis OSS or Memcached, how they compare, cache security, and the lazy loading, write-through, session store and leaderboard patterns.