Skip to content

Remove the prod Aurora reader replica (-$43/mo, gives up automatic failover) #1096

Closed

Description

@athvin

infra/terraform/envs/prod/rds.tf runs the prod Aurora Serverless v2 cluster
with two instances — a writer plus a reader in a second AZ. Owner cost decision
on 2026-11-16: remove the reader, accepting the loss of automatic failover.

Measured

The cluster is pinned to its capacity floor, so the reader is buying failover
rather than capacity:

aws cloudwatch get-metric-statistics --namespace AWS/RDS \
  --metric-name ServerlessDatabaseCapacity \
  --dimensions Name=DBClusterIdentifier,Value=er-prod \
  --period 86400 --statistics Average Maximum
day avg ACU max ACU
11-09 0.52 5.0
11-10 0.51 7.0
11-11 0.52 4.0
11-12 0.53 5.0
11-13 0.51 4.5
11-14 0.52 11.0
11-15 0.51 4.5

min_capacity is 0.5, so average 0.51 ACU is the floor. Saving is one instance
at that floor: 0.5 ACU x $0.12/ACU-hr x 730 hr = ~$43/month.

Prod is genuinely serving traffic (er-prod-edge ALB: 500–7,200 requests/day,
3–4 sustained DB connections), so this is not an idle-environment teardown. What
is given up is real:

  • an instance or AZ failure becomes an outage until someone promotes a
    replacement, rather than a failover;
  • a maintenance restart becomes visible downtime.

The trap this ticket exists to avoid

identifier = "er-prod-${count.index + 1}" means Terraform index [1] is
er-prod-2. er-prod-2 is the current writer (er-prod-1 is the reader):

aws rds describe-db-clusters --db-cluster-identifier er-prod \
  --query 'DBClusters[0].DBClusterMembers[].[DBInstanceIdentifier,IsClusterWriter]'
er-prod-1  False
er-prod-2  True

A count = 2 -> 1 shrink destroys the highest index — so the obvious edit
deletes the live writer and forces a failover on a production database instead
of removing the idle replica.

Fix is to key the resource by identifier instead of index, with moved blocks
carrying the existing instances onto the new addresses. Keying by name also
removes the latent hazard permanently: which instance is the writer is runtime
state that Aurora reshuffles on every failover, so an index-keyed resource can
never express "destroy the reader" reliably.

Acceptance

infra.yml's plan job on the PR must show exactly one destroy,
aws_rds_cluster_instance.prod["er-prod-1"], and no create and no replace. Do
not merge on anything else — infra.yml applies on merge to main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    followup

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions