terraform-aws-rds icon indicating copy to clipboard operation
terraform-aws-rds copied to clipboard

skip_final_snapshot=false causes destroy failure

Open razorsedge opened this issue 4 years ago • 3 comments

Describe the Bug

When skip_final_snapshot = false, running terraform destroy fails to delete the RDS option group.

Expected Behavior

Terraform destroy should not fail. If skip_final_snapshot = false, then this module should not attempt to destroy aws_db_option_group.default.

Steps to Reproduce

  1. Configure the basic example confirming that parameter skip_final_snapshot = false.
  2. terraform apply
  3. terraform destroy
  4. See error

Screenshots

If applicable, add screenshots or logs to help explain your problem.

$ terraform destroy
[snip]
module.database.aws_db_option_group.default[0]: Still destroying... [id=rds-default, 14m31s elapsed]
module.database.aws_db_option_group.default[0]: Still destroying... [id=rds-default, 14m41s elapsed]
module.database.aws_db_option_group.default[0]: Still destroying... [id=rds-default, 14m51s elapsed]

Error: Error Deleting DB Option Group: InvalidOptionGroupStateFault: The option group 'rds-default' cannot be deleted because it is in use.
	status code: 400, request id: 9f1a4a8a-5e45-4add-aaa6-df3612e44b4e


Releasing state lock. This may take a few moments...

Environment (please complete the following information):

  • Terraform: v0.12.29
  • provider.aws v2.70.0

Additional Context

RDS will not delete the DB option group because the final snapshot references it. If the final snapshot is deleted, the DB option group can be removed. This is not a Terraform problem, but how RDS works.

razorsedge avatar Sep 21 '20 17:09 razorsedge

@razorsedge have you tried setting the module with enabled = false and then run terraform apply?

jamengual avatar Sep 21 '20 17:09 jamengual

@jamengual I have not. And I am not clear on why I would when I want to destroy the entire configuration, not disable it.

razorsedge avatar Sep 21 '20 19:09 razorsedge

I was wondering if it could have differently but I do not think it will now that I think about it.

@razorsedge We are happy to receive PRs so feel free to create one ands send it over

jamengual avatar Sep 21 '20 19:09 jamengual