Architecture · All ADRs
ADR 0018 — Database read replicas with a write-only master password
Architecture decision record — status: Accepted (2026-10-08). First decided as "no replicas" (option 1); option 3 implemented the same day..
Status: Accepted (2026-10-08). First decided as "no replicas" (option 1); option 3 implemented the same day.
Context#
The RDS module lets RDS generate, store and rotate the master password in Secrets Manager
(manage_master_user_password), so the password never enters Terraform state (infra/terraform/README.md,
"Secrets never enter Terraform state").
The first production apply (2026-10-07, docs/operations/production-deployment-evidence.md) showed that
RDS refuses CreateDBInstanceReadReplica for a PostgreSQL source with ManageMasterUserPassword enabled.
The same restriction applies to the cross-region replica the DR design relies on (modules/dr-region,
docs/operations/multi-region.md).
Options considered:
- No replica (keep RDS-managed passwords). All reads go to the Multi-AZ primary.
- Terraform-generated master password (
random_password→password). Enables replicas, but the password lands in Terraform state (KMS-encrypted, restricted, like the ElastiCache AUTH token), which weakens the state's secret-free property for the most privileged database credential. - Write-only password attributes (
password_wo, Terraform ≥ 1.11 ephemeral values). Enables replicas and keeps the password out of state, but needs a Terraform upgrade from the validated 1.3 line across every stack, CI and the lock files.
Decision#
- Option 3. Terraform ≥ 1.11 everywhere (1.16.5 in use, CI included). The RDS module generates the master
password as an ephemeral
random_passwordand sends it through write-only arguments:password_woon the instance andsecret_string_woon the module's own Secrets Manager secret<name>/rds-master(same{username, password}JSON as the RDS-managed secret it replaces). Neither state nor plan files contain it. - Rotation: increment
master_password_version; RDS and the secret receive the new value in the same apply. - Read replicas are allowed again: production and the dedicated model enable the in-region replica, the secrets
bootstrap writes
replica_urland the production overlay mapsDATABASE_REPLICA_URL; the cross-region DR replica (modules/dr-region) is possible again. - Option 2 is rejected: it trades a security property for a capacity feature.
- (Interim, superseded the same day: option 1, no replicas, with a plan-time guard. Removed with option 3.)
Consequences#
- RDS no longer rotates the master password on its own; rotation is an operator action (
master_password_version). - The ephemeral password is new on every run, so the instance and the secret must receive it in the same apply:
the secret version depends on the instance (written only after it exists) and is replaced with it. If an
apply creates the instance but fails before writing the secret, increment
master_password_versionand apply again: both then receive one new value. - State written by Terraform 1.16 cannot be read by older versions: operator machines and CI upgrade together.
- Environments created before this change used the RDS-managed secret; all were destroyed when it was made, so no state migration was needed (a live environment would need the new secret and a password version bump).