Terraform ignores skip_final_snapshot so it's impossible to delete rds db instance
Problem
Hi, I've noticed that terraform (I'm using 0.6.9) ignores skip_final_snapshot argument for RDS DB instance resource that I need to remove: [code block] I'm getting the following error trying to remove DB instance: - aws_db_instance.db_instance: DB Instance FinalSnapshotIdentifier is required when a final snapshot is required Adding final_snapshot_identifier argument doesn't help -- result is the same, terraform fails. tfstate (sensitive data is removed): [code block]
Error Output
error trying to remove DB instance:
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix Terraform RDS DB Instance Deletion Issue by Updating Configuration
The issue arises because Terraform version 0.6.9 does not properly handle the 'skip_final_snapshot' argument for RDS DB instances. When this argument is set to true, Terraform still expects a final snapshot identifier, leading to the error when attempting to delete the instance.
Awaiting Verification
Be the first to verify this fix
- 1
Upgrade Terraform to a Compatible Version
Upgrade Terraform to a version that correctly supports the 'skip_final_snapshot' argument for RDS DB instances. Versions 0.7.0 and above have improved support for this feature.
bashterraform init -upgrade - 2
Modify Terraform Configuration
Ensure that your RDS DB instance resource configuration includes 'skip_final_snapshot = true' and remove any 'final_snapshot_identifier' argument if present. This allows Terraform to skip taking a final snapshot during deletion.
hclresource "aws_db_instance" "db_instance" { # other configurations skip_final_snapshot = true } - 3
Re-apply Terraform Configuration
After making the necessary changes, run 'terraform apply' to ensure the new configuration is applied and the state is updated.
bashterraform apply - 4
Delete the RDS DB Instance
Attempt to delete the RDS DB instance again using 'terraform destroy' or by removing the resource from your configuration and running 'terraform apply'. This should now succeed without errors.
bashterraform destroy -target=aws_db_instance.db_instance
Validation
Confirm that the RDS DB instance is successfully deleted without errors. You can verify this by checking the AWS Management Console or running 'terraform state list' to ensure the instance no longer appears in the state.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep