Skip to content

Instantly share code, notes, and snippets.

@ycku
Created April 26, 2025 09:42
Show Gist options
  • Save ycku/67dc18e2274e3863b8e02111c594b433 to your computer and use it in GitHub Desktop.
Save ycku/67dc18e2274e3863b8e02111c594b433 to your computer and use it in GitHub Desktop.
Connect RDS for PostgreSQL with Secret Manager
export RDSHOST="rds.hostname"
export SECRETID="secret-id"
export SECRETSTRING=$(aws secretsmanager get-secret-value --secret-id "${SECRETID}" --query SecretString --output text)
export PGHOST="${RDSHOST}"
export PGUSER=$(echo "${SECRETSTRING}" | jq -r '.username')
export PGPASSWORD=$(echo "${SECRETSTRING}" | jq -r '.password')
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "secretsmanager:GetSecretValue",
"Resource": "secret-arn"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment