Terraform-provider-aws: aws_vpc_dhcp_options_association cannot be destroyed when vpc is manually deleted

Created on 27 Jul 2020  ·  4Comments  ·  Source: hashicorp/terraform-provider-aws

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

$ terraform version
Terraform v0.12.20
+ provider.aws v2.70.0

Affected Resource(s)

  • aws_vpc_dhcp_options_association

Terraform Configuration Files

  • main.tf
provider "aws" {
  access_key = var.ACCESS_KEY_ID
  secret_key = var.SECRET_ACCESS_KEY
  region     = "eu-west-1"
}

resource "aws_vpc_dhcp_options" "vpc_dhcp_options" {
  domain_name         = "eu-west-1.compute.internal"
  domain_name_servers = ["AmazonProvidedDNS"]
}

resource "aws_vpc" "vpc" {
  cidr_block           = "10.222.0.0/16"
  enable_dns_support   = true
  enable_dns_hostnames = true
}

resource "aws_vpc_dhcp_options_association" "vpc_dhcp_options_association" {
  vpc_id          = aws_vpc.vpc.id
  dhcp_options_id = aws_vpc_dhcp_options.vpc_dhcp_options.id
}

Debug Output

Panic Output

Expected Behavior

terraform destroy to be able to destroy even when the vpc is manually deleted.

Actual Behavior

terraform destroy fails to destroy when the vpc is manually deleted.

Steps to Reproduce

  1. terraform apply
$ terraform apply -var-file=creds.tfvars

aws_vpc.vpc: Creating...
aws_vpc_dhcp_options.vpc_dhcp_options: Creating...
aws_vpc_dhcp_options.vpc_dhcp_options: Creation complete after 2s [id=dopt-0f75930fb1a3d1234]
aws_vpc.vpc: Creation complete after 8s [id=vpc-025b8d051734e1234]
aws_vpc_dhcp_options_association.vpc_dhcp_options_association: Creating...
aws_vpc_dhcp_options_association.vpc_dhcp_options_association: Creation complete after 1s [id=dopt-0f75930fb1a3d1234-vpc-025b8d051734e1234]

Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
  1. Delete manually the created vpc
aws ec2 delete-vpc --vpc-id vpc-025b8d051734e1234
  1. Ensure that terraform destroy fails to destroy the aws_vpc_dhcp_options_association
$ terraform destroy -var-file=creds.tfvars

aws_vpc_dhcp_options_association.vpc_dhcp_options_association: Destroying... [id=dopt-0f75930fb1a3d1234-vpc-025b8d051734e1234]

Error: InvalidVpcID.NotFound: The vpc ID 'vpc-025b8d051734e1234' does not exist
    status code: 400, request id: foo

Important Factoids

References

  • #0000
bug servicec2

Most helpful comment

Related to: https://github.com/terraform-providers/terraform-provider-aws/issues/13826

The fix for this has been merged and will release with version 3.1.0 of the Terraform AWS Provider, Thursday next week. Thanks to @DrFaust92 for the fix. 👍

All 4 comments

opened #14367 to fix

Related to: https://github.com/terraform-providers/terraform-provider-aws/issues/13826

The fix for this has been merged and will release with version 3.1.0 of the Terraform AWS Provider, Thursday next week. Thanks to @DrFaust92 for the fix. 👍

This has been released in version 3.1.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

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