Terraform Wants to Replace the Database. Apply Now?

A routine terraform plan unexpectedly wants to destroy and recreate the production database. Defend whether to apply, and how.

advanced14 min5 roundsTerraform

Answer key reviewed by Branko Petric

Read first: Terraform Fundamentals for DevOps

Your decision

Your terraform plan for a small tag change shows it will destroy and recreate the production RDS instance (force replacement). It is mid-afternoon, peak traffic. Do you apply now, and if not, what do you do instead?

The situation

You open a pull request that changes one tag on your RDS instance. CI runs terraform plan. Instead of a quiet in-place update, the plan reports: aws_db_instance.main must be replaced with # forces replacement next to one attribute, and a summary of 1 to destroy, 1 to add.

Context

It is 2:40 PM on a Tuesday, near peak traffic. The instance holds live production data. Hourly automated snapshots are enabled. Three other engineers are waiting on this PR to merge so they can rebase. The CI pipeline has an apply step that is one approval click away.

More: Terraform scenario interview questions