1. Introduction & use cases
Amazon RDS (Relational Database Service) runs databases such as PostgreSQL, MySQL, MariaDB, SQL Server and Oracle for you. AWS handles installation, patching, automated backups, point-in-time recovery, monitoring and optional Multi-AZ standby replicas for high availability. Aurora is AWS’s cloud-native MySQL/PostgreSQL-compatible engine.
You still design the schema, write queries and choose the size – but you no longer maintain the database server itself.
Where it is used
- Production database for web apps and APIs
- Replacing a self-managed MySQL/PostgreSQL on a VM
- Read replicas for reporting and scaling reads
- Databases that need automated backups and failover
2. Prerequisites
| You need | Version / notes |
|---|---|
| AWS account | With MFA on the root user and a non-root admin identity |
| AWS CLI v2 | Installed and configured – see the AWS guide |
| VPC | The default VPC is fine to start; production uses private subnets |
| Client | psql / mysql CLI, DBeaver or pgAdmin |
| Local DB for development | PostgreSQL/MySQL in Docker |
3. Local setup
1Develop against a local database
Use the same engine and major version locally as in RDS.
BASHdocker run -d --name pg -p 5432:5432 -e POSTGRES_PASSWORD=dev -e POSTGRES_DB=app postgres:17 psql "postgres://postgres:dev@localhost:5432/app" -c "select version();"2Create the RDS instance
RDS console → Create database → Standard create → PostgreSQL (or MySQL) → template Dev/Test or Production → instance
db.t4g.micro/small→ storage gp3 20 GB → Manage master credentials in AWS Secrets Manager → Public access: No → a new security grouprds-sg.3Allow only your app servers
Edit
rds-sginbound rules: PostgreSQL 5432 (MySQL 3306) from the app’s security group (e.g.ec2-app-sg), not from 0.0.0.0/0.OUTPUTType Port Source PostgreSQL 5432 sg-0abc… (ec2-app-sg)
4. Create & run a project
1Get the endpoint and password
Copy the endpoint from the console (Connectivity & security). The master password is in Secrets Manager.
BASHaws rds describe-db-instances --db-instance-identifier app-db --query "DBInstances[0].Endpoint.Address" --output text aws secretsmanager get-secret-value --secret-id <secret-arn> --query SecretString --output text2Connect from the EC2 instance with TLS
Download the RDS CA bundle and verify the server certificate.
BASHsudo apt install -y postgresql-client curl -o global-bundle.pem https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem psql "host=app-db.xxxx.ap-south-1.rds.amazonaws.com port=5432 dbname=postgres user=postgres sslmode=verify-full sslrootcert=global-bundle.pem"3Create the app database and user
Do not let the app use the master user.
SQLCREATE DATABASE app; CREATE USER app_user WITH PASSWORD 'strong-password'; GRANT ALL PRIVILEGES ON DATABASE app TO app_user; \c app GRANT ALL ON SCHEMA public TO app_user;4Connect from your laptop through an SSH tunnel
The database is private, so tunnel through the EC2 instance, then connect to
localhost:5433.BASHssh -i ~/.ssh/my-ec2-key.pem -N -L 5433:app-db.xxxx.ap-south-1.rds.amazonaws.com:5432 ubuntu@<EC2_IP> psql "postgres://app_user@localhost:5433/app?sslmode=require"
✅ When it works you should see output like Figure 1.
5. Development configuration
Environment variables
Keep the connection string out of code. On AWS, read the secret from Secrets Manager at startup (via the instance/task role) or inject it as an environment variable during deployment.
DATABASE_URL=postgres://app_user:PASSWORD@app-db.xxxx.ap-south-1.rds.amazonaws.com:5432/app?sslmode=verify-full&sslrootcert=/etc/ssl/rds/global-bundle.pem
DB_SECRET_ARN=arn:aws:secretsmanager:ap-south-1:123456789012:secret:rds!db-xxxxKey dependencies
| Package / tool | Used for |
|---|---|
RDS engine | PostgreSQL or MySQL (match local major version) |
Security groups | Network access only from app servers |
Secrets Manager | Master/app passwords with rotation |
RDS CA bundle | TLS verification |
pg / mysql2 / psycopg / PDO | Drivers in your app |
Performance Insights / CloudWatch | Query and resource monitoring |
Folder structure
app/
├── migrations/ # schema changes (Prisma, Knex, Alembic, Flyway…)
├── src/db.js # pool using DATABASE_URL
└── certs/global-bundle.pemEssential commands
| Command | What it does |
|---|---|
aws rds describe-db-instances | List instances and endpoints |
aws rds create-db-snapshot --db-instance-identifier app-db --db-snapshot-identifier app-db-pre-release | Manual snapshot |
pg_dump / mysqldump | Logical backups |
aws rds reboot-db-instance | Reboot (applies some parameter changes) |
6. Production deployment
Server & hosting requirements
| Requirement | Recommendation |
|---|---|
| Network | Private subnets, no public access, SG from app only |
| High availability | Multi-AZ for production |
| Backups | Automated backups 7–35 days + snapshots before releases |
| Security | Encryption at rest, TLS in transit, Secrets Manager |
| Sizing | Start small (t4g), watch CPU/memory/IOPS and scale |
Deployment steps
1Production settings
Modify the instance: enable Multi-AZ, set backup retention (e.g. 14 days), enable deletion protection, encryption (on by default for new instances), Performance Insights and auto minor version upgrades in a maintenance window.
2Run migrations from your deploy pipeline
Apply schema changes as a separate, logged step before switching the app to the new version.
BASH# examples npx prisma migrate deploy python manage.py migrate npx knex migrate:latest3Snapshot before risky releases
A manual snapshot is kept until you delete it.
BASHaws rds create-db-snapshot --db-instance-identifier app-db --db-snapshot-identifier app-db-before-v24Monitor and alert
CloudWatch alarms on
CPUUtilization,FreeStorageSpace,DatabaseConnectionsandFreeableMemory; enable storage autoscaling.5Test a restore
Restore a snapshot to a new instance (point-in-time recovery) and connect to it – the only way to know backups work.
🗺 The whole path from your code to the live site is drawn in the deployment diagram.
7. Images & screenshots
Illustrations drawn for this guide from the commands above. Product dashboards change often, so for screens such as cloud consoles follow the step text and the official documentation.
8. Common errors & solutions
Connection times out
Security group does not allow your source, the instance is private and you are outside the VPC, or wrong port. Allow the app SG or use an SSH tunnel.
password authentication failed
Wrong user/password, or the password was rotated in Secrets Manager – read the current secret.
SSL connection is required / certificate verify failed
Use sslmode=verify-full with the current RDS CA bundle (global-bundle.pem).
too many connections
Each app process opens a pool. Reduce pool sizes, use RDS Proxy, or choose a larger instance class.
Storage full, database read-only
Enable storage autoscaling and alarm on FreeStorageSpace.
Best practices
- Never make production databases publicly accessible.
- Use a dedicated app user, not the master user.
- Multi-AZ, automated backups and deletion protection in production.
- Use connection pooling and RDS Proxy for serverless apps.
- Keep local, staging and production on the same engine major version.