Summary
Currently, all EventGate Lambdas connect to the database using the postgres superuser. This is a significant security anti-pattern — the application should use least-privilege, role-specific database credentials instead of a superuser account.
Problem
- Every Lambda function uses the
postgres user for DB access, regardless of what operations it actually performs.
- A compromised or buggy Lambda currently has full superuser access to the database (schema changes, other roles' data, etc.), far beyond what it needs.
- This is effectively the worst-case DB security posture for the application.
Proposed Change
- Update Lambdas to authenticate using the appropriate custom DB role(s) instead of
postgres.
- Custom role credentials are (or will be) stored in AWS Secrets Manager (see companion infrastructure issue in
cps-eventbus-gateway for provisioning these secrets).
- Pass the relevant Secrets Manager secret ARN into each Lambda so it can retrieve its DB credentials at runtime — likely via an environment variable (e.g.
DB_SECRET_ARN), then resolved through the AWS SDK/Secrets Manager client during cold start or connection setup.
- Ensure Lambda IAM roles are granted
secretsmanager:GetSecretValue scoped to only the specific secret(s) they need.
- Update DB connection/init code to fetch the username/password from the resolved secret instead of using hardcoded/
postgres credentials.
Acceptance Criteria
Dependencies
Summary
Currently, all EventGate Lambdas connect to the database using the
postgressuperuser. This is a significant security anti-pattern — the application should use least-privilege, role-specific database credentials instead of a superuser account.Problem
postgresuser for DB access, regardless of what operations it actually performs.Proposed Change
postgres.cps-eventbus-gatewayfor provisioning these secrets).DB_SECRET_ARN), then resolved through the AWS SDK/Secrets Manager client during cold start or connection setup.secretsmanager:GetSecretValuescoped to only the specific secret(s) they need.postgrescredentials.Acceptance Criteria
postgres.Dependencies