Amazon RDS and Aurora for Developers: Connections, RDS Proxy, IAM Authentication, Read Replicas and Backups

AWS Developer Associate 50 min min read Updated: Nov 17, 2026 Intermediate
Amazon RDS and Aurora for Developers: Connections, RDS Proxy, IAM Authentication, Read Replicas and Backups
Intermediate Topic 1 of 3

RDS in One Page

Amazon RDS runs managed relational databases: MySQL, PostgreSQL, MariaDB, Oracle, SQL Server and Db2. Amazon Aurora is AWS's cloud-built MySQL- and PostgreSQL-compatible engine. AWS handles hardware, OS patching, backups and failover. You handle schema, queries, access and tuning. You cannot SSH into the host (RDS Custom is the exception).

FeatureWhat it gives you
Multi-AZSynchronous standby in another AZ with automatic failover (high availability, not for reads in classic Multi-AZ)
Read replicasAsynchronous copies for read scaling, can be in another Region, can be promoted. Up to 15 for Aurora, 15 for MySQL/PostgreSQL on RDS
Automated backupsDaily snapshot plus transaction logs. Point-in-time restore within retention of 1 to 35 days
Manual snapshotsKept until you delete them. Can be copied and shared
Storage autoscalingGrows storage automatically up to a limit
EncryptionKMS at rest (choose when creating; encrypt later via snapshot copy). SSL/TLS in transit

Endpoints Matter

EngineEndpointUse
RDS instanceOne DNS name that always points to the current primary (changes during failover, so respect DNS TTL)Read and write
Aurora cluster (writer) endpointAlways the current writerWrites
Aurora reader endpointLoad-balances across Aurora replicasReads
Aurora custom endpointsA chosen subset of instancesReporting group, different instance sizes
RDS Proxy endpointPooled connections in front of the databaseLambda and many short clients

Never hard-code an instance IP. Use the endpoint, keep short DNS caching in your driver, and retry on connection errors during failover (typically around a minute for RDS Multi-AZ, usually shorter for Aurora).

Connecting from Code

python import json, boto3, pymysql _secret = None def get_secret(): global _secret if _secret is None: # cache between warm invocations sm = boto3.client("secretsmanager") _secret = json.loads(sm.get_secret_value(SecretId="shop/db")["SecretString"]) return _secret conn = None def get_conn(): global conn if conn is None or not conn.open: s = get_secret() conn = pymysql.connect(host=s["host"], user=s["username"], password=s["password"], database="shop", connect_timeout=5, ssl={"ca": "/opt/global-bundle.pem"}) return conn def handler(event, context): with get_conn().cursor() as cur: cur.execute("SELECT id, total FROM orders WHERE customer_id = %s", (event["customerId"],)) return cur.fetchall()
  • Always use parameterized queries (%s placeholders) to prevent SQL injection
  • Never store passwords in code. Read them from Secrets Manager (supports automatic rotation for RDS) or use IAM authentication
  • Verify the server certificate using the RDS CA bundle

The Lambda Connection Problem and RDS Proxy

Each concurrent Lambda environment opens its own database connection. A traffic spike of 1,000 concurrent executions can open 1,000 connections and exhaust the database (a small instance may allow only a few hundred). RDS Proxy fixes this.

text Lambda (1000 envs) ──► RDS Proxy (pool, ~50 DB connections) ──► RDS / Aurora ├─ multiplexes many clients onto fewer connections ├─ keeps connections during failover (failover time cut up to ~66%) └─ credentials from Secrets Manager, supports IAM auth
  • Runs in your VPC, so the Lambda function must be in the VPC as well
  • Supports MySQL, PostgreSQL, MariaDB and SQL Server engines (check the list for your version)
  • Watch for pinning (session-level state like temporary tables or SET statements force a client to hold one connection)
  • Alternatives for HTTP-style access: the RDS Data API for Aurora Serverless (no connection management)

IAM Database Authentication

Instead of a stored password, the app asks AWS for a token valid for 15 minutes and uses it as the password. Access is controlled with IAM policy rds-db:connect. Works for MySQL, PostgreSQL and MariaDB with SSL required.

python rds = boto3.client("rds") token = rds.generate_db_auth_token(DBHostname="shop.cluster-abc.ap-south-1.rds.amazonaws.com", Port=3306, DBUsername="app_user", Region="ap-south-1") conn = pymysql.connect(host="shop.cluster-abc.ap-south-1.rds.amazonaws.com", user="app_user", password=token, database="shop", ssl={"ca": "/opt/global-bundle.pem"})
json {"Effect": "Allow", "Action": "rds-db:connect", "Resource": "arn:aws:rds-db:ap-south-1:111111111111:dbuser:cluster-ABCDEFG/app_user"}
  • Only new connections need a valid token; open connections continue
  • Limit: connections per second with IAM auth is limited, so use a pool or RDS Proxy for very busy apps

Multi-AZ vs Read Replica Summary

Multi-AZ (instance)Read replica
PurposeHigh availabilityRead scaling, DR across Regions
ReplicationSynchronousAsynchronous (replica lag)
Used for readsNo (Multi-AZ DB cluster option has readable standbys)Yes
FailoverAutomaticManual promotion (or automatic in Aurora)
BackupsTaken from the standbyCan have own backup settings
EndpointSame DNS nameOwn endpoint. App must route reads

Aurora Highlights

  • Storage is a shared cluster volume replicated 6 ways across 3 AZs, growing automatically to 128 TiB
  • Up to 15 low-lag replicas. Failover to a replica usually in under 30 seconds (priority tiers decide who is promoted)
  • Aurora Serverless v2 scales capacity (ACUs) in small steps up and down automatically. Good for variable or new workloads
  • Aurora Global Database: cross-Region replication under about a second for DR and local reads
  • Backtrack (Aurora MySQL) rewinds the cluster without restoring a backup
  • Cloning creates a fast copy-on-write copy for testing
  • Aurora reads use the reader endpoint, writes the cluster endpoint

Backups and Restore

  • Restore always creates a new instance or cluster (new endpoint). You then repoint the app, you do not restore in place
  • Point-in-time restore to a second within the retention period (up to 35 days)
  • Snapshots can be copied across Regions, shared and restored into other accounts
  • Set deletion protection and take a final snapshot when deleting

Parameter Groups and Option Groups

  • Parameter group: engine settings such as max_connections, time zone or innodb_buffer_pool_size. Static parameters need a reboot, dynamic parameters apply immediately
  • Option group: extra engine options (for example Oracle or SQL Server features)
  • You cannot edit the default group. Create a custom one

Monitoring

  • CloudWatch metrics: CPUUtilization, DatabaseConnections, FreeableMemory, ReadLatency, ReplicaLag, FreeStorageSpace
  • Performance Insights shows top SQL and waits
  • Enhanced Monitoring gives OS-level metrics
  • Slow query log and error logs can export to CloudWatch Logs
  • RDS events through SNS for failover, backup and maintenance

Choose RDS or DynamoDB?

NeedPick
Joins, transactions across many tables, SQL reporting, existing SQL appRDS / Aurora
Key-based access at massive scale, serverless, flexible schemaDynamoDB
Variable relational workloadAurora Serverless v2

Practice Tasks

  1. Create an Aurora MySQL or PostgreSQL cluster and connect with a client
  2. Store the credentials in Secrets Manager and read them from code
  3. Put an RDS Proxy in front and connect a Lambda function in the VPC
  4. Create a read replica and send reads to it
  5. Restore a point-in-time copy to a new instance and compare data

Conclusion

Use endpoints not IPs, keep credentials in Secrets Manager or use IAM authentication, parameterize queries, add RDS Proxy for Lambda and bursty clients, use Multi-AZ for availability and read replicas for read scale, restore into new instances, and watch connections, CPU and replica lag.

Quick Summary: RDS features; endpoints; code connection; RDS Proxy; IAM auth; Multi-AZ vs replicas; Aurora; backups; parameter groups; monitoring.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators