Sub topic 2
Connecting and Managing Credentials
Assume you understand SQL connections, AWS IAM, VPC security groups, and basic AWS CLI use. An RDS endpoint is a DNS name that points to your database instance. Applications should use this endpoint instead of an IP address.
Connect Securely
RDS can store the master password in AWS Secrets Manager when you create the instance with --manage-master-user-password. Grant access to the secret through IAM, and retrieve it at runtime rather than placing it in source code or a configuration file.
Use TLS (Transport Layer Security) for the connection. With verify-full, the client checks both the certificate and the endpoint hostname.
psql "host=demo-pg.example.us-east-1.rds.amazonaws.com port=5432 dbname=postgres user=appadmin sslmode=verify-full sslrootcert=global-bundle.pem"The security group should allow port 5432 only from approved application security groups. Do not make the database publicly accessible unless there is a specific, controlled reason.
Encrypt Data at Rest and in Transit
Encryption at rest protects database files, automated backups, snapshots, and read replicas. Enable it when you create the instance. For stronger control, use a customer-managed AWS KMS key and manage its key policy carefully.
Encryption in transit protects traffic between clients and RDS. Download the current RDS CA bundle, configure sslmode=verify-full, and keep certificate validation enabled. Encryption does not replace authorization. A valid TLS connection still needs valid database credentials.
Backups, Snapshots, and Point-in-Time Restore
Automated backups retain transaction and storage data for the configured period. Point-in-time restore uses those backups to create a new instance close to a selected time. A manual snapshot is a user-controlled copy that remains until you delete it.
aws rds restore-db-instance-to-point-in-time \
--source-db-instance-identifier demo-pg \
--target-db-instance-identifier demo-pg-restored \
--use-latest-restorable-timeThe restored instance has a new endpoint. Test restores regularly so you know the recovery process works.
High Availability with Multi-AZ
A Multi-AZ deployment maintains a standby in another Availability Zone. RDS replicates changes to that standby and moves the endpoint during many infrastructure failures or maintenance events. Applications reconnect using the same endpoint.
Multi-AZ improves availability, but the standby is not a read-only scaling target. Use read replicas when you need additional read capacity.
Exercise
Should you use Multi-AZ or a read replica to handle more read queries?
Show answer
Use a read replica. Multi-AZ is for availability and failover.