Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save williams9438/5fa56fd1447d270b5ead5b594cb93d4d to your computer and use it in GitHub Desktop.
Save williams9438/5fa56fd1447d270b5ead5b594cb93d4d to your computer and use it in GitHub Desktop.
How to connect a Heroku application to an Amazon RDS PostgreSQL instance, forcing SSL and certificate chain verification

1 - Download the RDS certificates (root plus region-specific intermediate ones) bundle:

wget -O config/rds-combined-ca-bundle.pem https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem

2 - Add config/rds-combined-ca-bundle.pem to the repository and redeploy to Heroku.

3 - Update the DATABASE_URL env var:

'postgres://user:password@host/db_name?sslmode=verify-full&sslrootcert=config/rds-combined-ca-bundle.pem'

do not forget to surround with quotes

References:

@williams9438
Copy link
Author

williams9438 commented Dec 14, 2021

Note: For postgres set db_name as postgres for it to work while host is aws endpoint : port

Example: postgres://username:password@database_name.ceb4nertmwp.us-east-1.rds.amazonaws.com:5432/postgres?sslmode=verify-full&sslrootcert=config/rds-combined-ca-bundle.pem

Ref: https://stackoverflow.com/questions/51014647/aws-postgres-db-does-not-exist-when-connecting-with-pg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment