1
votes

export TF_WARN_OUTPUT_ERRORS=1

terraform destroy

Error: Error applying plan:

2 error(s) occurred:

  • module.dev_vpc.aws_internet_gateway.eks_vpc_ig_gw (destroy): 1 error(s) occurred:

  • aws_internet_gateway.eks_vpc_ig_gw: Error waiting for internet gateway (0980f3434343410c209) to detach: timeout while waiting for state to become 'detached' (last state: 'detaching', timeout: 15m0s)

  • module.dev_vpc.aws_subnet.production_public_subnets[1] (destroy): 1 error(s) occurred:

  • aws_subnet.production_public_subnets.1: error deleting subnet (subnet-04ad0a3a0171c861c): timeout while waiting for state to become 'destroyed' (last state: 'pending', timeout: 20m0s)

2
Can you try again? Also make sure you don't have any resources in the VPC that would have public IP. You can't detach internet gateway if you have still NAT gateway there.Marcin
Can you edit your question to include an minimal reproducible example of self contained Terraform code that reproduces this error when you attempt to destroy? Without that it's hard to know exactly what you're doing wrong but it's likely either a structuring issue or a dependency issue where you need to tell Terraform the order of things to create and destroy.ydaetskcoR

2 Answers

3
votes

There was a load balancer attached to EC2 instance. I logon to AWS console, manually removed the load balancer, ran terraform destroy. It is successfully destroyed.

0
votes

Same issue I also faced, deployed whole infra with Terraform but deployed application manually and that in process created an ALB, small but painful. So first remove the infra which is not part of Terraform and then destroy will work fine.