Terraform-provider-aws: aws_route53_zone fails to destroy with HostedZoneNotEmpty even with force_destroy = true

Created on 15 Feb 2018  ยท  4Comments  ยท  Source: hashicorp/terraform-provider-aws

Terraform Version

Terraform v0.11.3

  • provider.aws v1.9.0
  • provider.null v1.0.0
  • provider.template v1.0.0

Affected Resource(s)

  • aws_route53_zone

Terraform Configuration Files

resource "aws_route53_zone" "s" {                                                                                                                                             
  name = "s.k8s-${var.region}.${data.terraform_remote_state.route53.domain}"                                                                                                  

  # external-dns deployment places things here beyond terraform's control                                                                                                     
  # if we are destroying the cluster, then these records should go to                                                                                                         
  # external-dns will re-populate anyway                                                                                                                                      
  force_destroy = true                                                                                                                                                        

  tags = {                                                                                                                                                                    
    Environment = "${var.env}"                                                                                                                                                
    Terraform   = true                                                                                                                                                        
  }                                                                                                                                                                           
}                                                                                                    

Debug Output

I have debug output, but I'm hesitant to post it on the internet because of the contents.

However, it looks like it's writing state for the object in question with force_destroy = false.

Panic Output

Expected Behavior

Terraform should delete all records in the Route53 zone, then delete the zone itself.

Actual Behavior

* aws_route53_zone.s: HostedZoneNotEmpty: The specified hosted zone contains non-required resource record sets  and so cannot be deleted.
        status code: 400, request id: 128b665e-1271-11e8-9d2f-f99c6c224f10

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform destroy

Important Factoids

This Route53 zone has RRs created by another tool (kubernetes' external-dns).

force_destroy on this resource was originally false when it was created. I only changed it to true prior to destroy, so I'm not sure if this is expected or not.

References

I thought this would have been fixed via https://github.com/hashicorp/terraform/issues/12407

question servicroute53

Most helpful comment

Does it work if you terraform apply the force_destroy = true change and then run terraform destroy?

All 4 comments

Does it work if you terraform apply the force_destroy = true change and then run terraform destroy?

Yes! I wonder if this behavior is documented anywhere? My expectation was that setting force_destroy would take effect without an apply, since it only concerns destroy operations. I guess what's really happening is destroy is only looking at state, not what's configured, correct?

Thank you for using Terraform and for opening up this question, @acobaugh! Issues on GitHub are intended to be related to bugs or feature requests with the provider codebase.

It looks like you have some solid feedback, so this issue will be closed. Please use our new community forum https://discuss.hashicorp.com/c/terraform-providers for additional feedback, community discussions, and questions around Terraform.

If you believe that your issue was miscategorized as a question or closed in error, please create a new issue using one of the following provided templates: bug report or feature request. Please make sure to provide us with the appropriate information so we can best determine how to assist with the given issue.

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

Was this page helpful?
0 / 5 - 0 ratings