hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.79k stars 9.14k forks source link

[Bug]: Error: PublicZoneVPCAssociation: Attempting to associate public zone #32773

Open EugenKon opened 1 year ago

EugenKon commented 1 year ago

Terraform Core Version

1.5.4

AWS Provider Version

5.10.0

Affected Resource(s)

aws_route53_zone

Expected Behavior

No error

Actual Behavior

Same as here https://github.com/hashicorp/terraform-provider-aws/issues/251

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_route53_zone" "private-cloud" {
  count         = var.use_dns ? 1 : 0
  name          = var.domain_name
  comment       = "HostedZone created by Route53 Registrar for ${var.project_name}"
  force_destroy = false

  dynamic "vpc" {
    for_each = var.vpc_id

    content {
      vpc_id = vpc.value
    }
  }
}

Steps to Reproduce

I do not have exact steps. What I did: var.use_dns was assigned to false so count is changed from 1 to 0.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

EugenKon commented 1 year ago

The plan:

  # module.dns.aws_route53_zone.private-cloud[0] will be updated in-place
  ~ resource "aws_route53_zone" "private-cloud" {
        id                  = "Z0803079GS4S3AQWFY1V"
        name                = "*hidden*"
        tags                = {}
        # (7 unchanged attributes hidden)

      + vpc {
          + vpc_id     = "vpc-0d639d3e779362f6b"
          + vpc_region = (known after apply)
        }
    }
EugenKon commented 1 year ago

As workaround I manually removed managed by terraform DNS records except NS and SOA
and manually removing hosted zone.