The plan says an RDS instance "must be replaced" after a small code change. What do you do before approving?
AdvancedScenarioImport Refactoring Drift and Lifecycle
Answer
Situation read → Some attribute changes force replacement, which for a database means data loss.
What I'd do →
- Find the line marked
# forces replacementin the plan. - Stop. Take a manual snapshot.
- Check whether the change can be made in place (
modifyvs recreate), such as a parameter group change orapply_immediately. - If replacement is unavoidable, restore from snapshot through
snapshot_identifieror plan a migration.
Why → The plan tells you which attribute is immutable; the fix is a design change, not a flag.
Interview tip → Recognising "forces replacement" in plans is a core skill.
More on Import Refactoring Drift and Lifecycle
An S3 bucket was created by hand in the console and now must be managed by Terraform. How do you bring it in?BeginnerYou must adopt 200 existing resources and don't want to write all the HCL by hand.IntermediateHow do you find out that someone changed infrastructure outside Terraform?BeginnerSomeone opened port 22 on a security group in the console. Terraform wants to remove it. What's your process?IntermediateAn Auto Scaling group's desired capacity is changed by autoscaling, and Terraform keeps resetting it.IntermediateHow do you protect a production database from an accidental `terraform destroy`?Beginner