Overview
The Address API uses RDS PostgreSQL 15 in private subnets. Direct connections are not possible - you must use a bastion host.Connection architecture
Prerequisites
- AWS CLI installed and configured
- Session Manager plugin installed
- Appropriate IAM permissions
Step 1: Configure security group
Add your IP to the RDS security group to allow connections:- Go to EC2 → Security Groups
- Find
{env}-address-api-postgres-sg - Click Edit inbound rules
- Click Add rule:
- Type: All traffic
- Source type: Anywhere-IPv4
- Description: Temporary access for debugging
- Click Save rules
Step 2: Connect to bastion host
- Go to EC2 → Instances
- Find
{env}-bastion-host - Click Connect
- Select Session Manager tab
- Click Connect
Step 3: Get database credentials
Retrieve credentials from Secrets Manager:Step 4: Connect to PostgreSQL
Construct the connection URL:psql:
Common database operations
List tables
iso_3166- ISO 3166 subdivision dataaddress_cache- Geocoding cacheapi_key- API keysatlas_schema_revisions- Migration history
Check table sizes
View recent cache entries
Count API keys by role
Check migration status
Troubleshooting
Error: “could not connect to server”
Cause: Security group not configured or bastion host can’t reach RDS. Fix:- Verify security group rules (Step 1)
- Check RDS is running: Go to RDS → Databases
- Verify bastion host is in the same VPC
Error: “password authentication failed”
Cause: Incorrect credentials. Fix:- Re-fetch credentials from Secrets Manager
- Ensure you’re using the correct environment’s secrets
- Check for special characters in password (may need URL encoding)
Error: “database does not exist”
Cause: Wrong database name. Fix: Useapp as the database name (default for Address API).
Security best practices
- Remove security group rules after debugging
- Use read-only queries when possible
- Never modify data in production without approval
- Log all database access for audit purposes
- Rotate credentials regularly