Skip to content

infra(dev): Aurora Serverless v2 Postgres for the dev env - #94

Merged
athvin merged 1 commit into
mainfrom
dev-aurora-postgres
Oct 15, 2026
Merged

athvin merged 1 commit into
mainfrom
dev-aurora-postgres

Conversation

@athvin

@athvin athvin commented Oct 15, 2026

Copy link
Copy Markdown
Owner

What

Adds infra/terraform/envs/dev/rds.tf — a pay-per-use managed Postgres for the dev env to replace the always-on in-cluster er-postgres StatefulSet.

Aurora Serverless v2 (PostgreSQL 17.9), min_capacity = 0 .. max 4 ACU — scales down to 0 (auto-pause) when idle, so an unused dev DB bills ~nothing. One shared cluster; prod will get its own provisioned cluster in a separate env.

Resources (terraform plan: 7 to add, 1 in-place tag on the metrics-server add-on):

  • aws_rds_cluster "er-dev" + one db.serverless instance, storage-encrypted, private-subnet-only
  • aws_db_subnet_group over module.network.private_subnet_ids
  • aws_security_group er-dev-db — 5432 from the VPC CIDR only, no public access
  • random_password master cred → endpoint + DSN published to Secrets Manager er/dev/shared/postgres (mirrors the er/dev/shared/s3 pattern) for scripts/dev_env.sh

Safety

  • No secrets in the repo — the password is generated at apply and lives only in Secrets Manager.
  • Plan validated against live AWS; the only non-create change is adding the standard Project/Environment/ManagedBy tags to the metrics-server add-on (imported into state in this change).

Not yet wired (follow-up)

dev_env.sh / the er-dev-namespace chart still provision the in-cluster StatefulSet. Cutting dev over to the shared cluster needs a per-dev database/role isolation decision — today each developer gets a fully private StatefulSet.

🤖 Generated with Claude Code

Replaces the always-on in-cluster er-postgres StatefulSet (EBS-backed) with a
pay-per-use managed cluster: Aurora Serverless v2 scales ACUs with load and
down to 0 when idle (min_capacity 0, supported on the resolved PG 17.9), so an
unused dev DB bills ~nothing. One shared cluster; prod gets its own provisioned
cluster in a separate env.

Adds infra/terraform/envs/dev/rds.tf:
  - aws_rds_cluster "er-dev" (aurora-postgresql, serverless v2 0..4 ACU),
    one db.serverless instance, storage-encrypted, private-subnet-only.
  - aws_db_subnet_group over module.network.private_subnet_ids.
  - aws_security_group er-dev-db: 5432 from the VPC CIDR only, no public access.
  - random_password master cred; endpoint + DSN published to Secrets Manager
    er/dev/shared/postgres for scripts/dev_env.sh (mirrors er/dev/shared/s3).

No secrets in the repo: the password is generated at apply and lives only in
Secrets Manager. versions.tf gains the hashicorp/random provider.

Not yet wired: dev_env.sh / the er-dev-namespace chart still provision the
in-cluster StatefulSet. Cutting dev over to the shared cluster needs a per-dev
database/role isolation decision (today each dev gets a private StatefulSet),
tracked as a follow-up.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@athvin
athvin merged commit f732383 into main Oct 15, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants