One way to connect to RDS PostgreSQL without a password

This approach assumes the user has a IAM username.

CREATE USER {db username};
GRANT rds_iam to {db_username};
wget https ://s3.amazonaws.com/rds-downloads/rds- ca-2019-root.pem
export PGPASSWORD="$(aws rds
generate-db-auth-token —hostname={dbendpoint} —port=54 32 —username={db_username}
—region us-west-2)"
psql -h {db_endpoint} -p 5432 "dbname={db_name} user=(db_username) password=$PGPASSWORD sslrootcert=/home/ec2-user/rds-combined-ca- bundle.pem sslmode=verify-ca"

Leave a Comment

Scroll to Top