Launch a PostgreSQL RDS instance, connect to it securely with VPC, manage credentials with Secrets Manager, and run migrations.
RDS runs PostgreSQL, MySQL, and other databases without you managing the server. AWS handles backups, OS patching, failover, and disk expansion. You get the same Postgres you know — without the ops.
aws rds create-db-instance \ --db-instance-identifier myapp-postgres \ --db-instance-class db.t3.micro \ --engine postgres \ --engine-version "15.4" \ --master-username appuser \ --master-user-password "$(openssl rand -base64 20)" \ --allocated-storage 20 \ --storage-type gp3 \ --no-publicly-accessible \ --vpc-security-group-ids sg-abc123 \ --backup-retention-period 7 \ --deletion-protection
aws secretsmanager create-secret \
--name prod/rds/myapp \
--secret-string '{
"host": "myapp-postgres.xyz.us-east-1.rds.amazonaws.com",
"port": 5432,
"dbname": "myapp",
"username": "appuser",
"password": "your-generated-password"
}'
import pg from 'pg';
import { SecretsManagerClient, GetSecretValueCommand } from '@aws-sdk/client-secrets-manager';
const sm = new SecretsManagerClient({ region: 'us-east-1' });
async function getDbConfig() {
const res = await sm.send(new GetSecretValueCommand({
SecretId: 'prod/rds/myapp'
}));
return JSON.parse(res.SecretString);
}
let pool;
export async function getPool() {
if (!pool) {
const config = await getDbConfig();
pool = new pg.Pool({
host: config.host,
port: config.port,
database: config.dbname,
user: config.username,
password: config.password,
ssl: { rejectUnauthorized: false }, // RDS requires SSL
max: 10,
idleTimeoutMillis: 30000,
});
}
return pool;
}
// Usage
const pool = await getPool();
const result = await pool.query('SELECT NOW()');
console.log(result.rows[0]);
npm install node-pg-migrate # package.json scripts "migrate:up": "node-pg-migrate up", "migrate:down": "node-pg-migrate down", "migrate:create": "node-pg-migrate create" # Run migrations against RDS (use the credentials from Secrets Manager) DATABASE_URL="postgresql://appuser:pass@host:5432/myapp" npm run migrate:up
db.t3.micro PostgreSQL 15 RDS instance in private modeprod/rds/myappusers tableThe foundations from today carry directly into Day 5. In the next session the focus shifts to Day 5 — building directly on everything covered here.
Before moving on, verify you can answer these without looking:
Live Bootcamp
Learn this in person — 2 days, 5 cities
Thu–Fri sessions in Denver, Los Angeles, New York, Chicago, and Dallas. $1,490 per seat. June–October 2026.
Reserve Your Seat →