Plan says `aws_db_instance.main must be replaced` after changing `storage_encrypted = true`.
AdvancedTroubleshootingPlan Errors and Unexpected Replacements
Answer
Likely causes → Encryption at rest can't be enabled in place on RDS; the provider marks it forces replacement. Applying would create a new empty DB and delete the old one.
Diagnose → terraform plan | grep -B2 'forces replacement'
Fix → Revert the change. Migrate deliberately: snapshot → copy snapshot with KMS encryption → restore to a new instance (in code, snapshot_identifier) → switch the app → remove the old one.
Prevent → lifecycle { prevent_destroy = true } and deletion_protection = true on stateful resources, and a CI gate that blocks any delete on RDS/S3/EFS/DynamoDB.
More on Plan Errors and Unexpected Replacements
`Error: Invalid for_each argument` — `The "for_each" map includes keys derived from resource attributes that cannot be determined until apply`.Intermediate`The given "for_each" argument value is unsuitable: the "for_each" argument must be a map, or set of strings, and you have provided a value of type list of string.`Beginner`Error: Invalid for_each argument` — `Sensitive values, or values derived from sensitive values, cannot be used as for_each arguments.`Intermediate`Error: Invalid count argument` — `The "count" value depends on resource attributes that cannot be determined until apply`.Intermediate`Error: Unsupported attribute` — `This object has no argument, nested block, or exported attribute named "public_ip_address"`.Beginner`Error: Unsupported attribute` on `module.vpc.private_subnets` — `This object does not have an attribute named "private_subnets"`.Beginner