-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failing to delete an already provisioned subnet if it was used for an Autoscaling Group (that created some EC2 instances) #9495
Comments
I've just experienced this same thing, believe it or not.
unfortunate this is an open issue. |
Any updates on this issue? I bumped into https://aws.amazon.com/blogs/compute/update-issue-affecting-hashicorp-terraform-resource-deletions-after-the-vpc-improvements-to-aws-lambda/ but I can't delete subnets even using provider v2.41. |
Hi folks 👋 If you are seeing
|
The orphaned ENI issue is also being worked here: |
I'm having the same issue as the OP when trying to change the availability zone of a subnet. Terraform wanted to update the auto scaling group in place, instead of destroying and recreating it. This made the subnet deletion fail as the subnet still had resources in it. There seems to be similar behavior for load balancers and RDS instances which terraform also wants to update in place. I ended up destroying pretty much the entire infrastructure and recreating from scratch, that was the only workaround I could find. |
I have the same issue. In my setup, I create a VPC, an EKS, multiple ASGs, etc. The good thing is that Terraform destroys the ASGs (and EC2 instance which are the costly resources). That bad is that the Internet Gateway, subnets, and network interfaces are left dangling. I have noticed that they eventually get cleaned up by what is likely a background cleanup job the AWS runs to deallocate dangling resources. |
Same problem for me. In my TF script I'm trying to remove one availability zone and all the resources belonging to it. It's not possible due to the fact, that TF is trying to remove the subnet and this can't be deleted because it still has resources in it. Any Ideas how to solve this problem? Any suggestion despite destroying everything? |
I tried with refreshing keys like Access key and Secret key |
For anyone who got here because of Jenkins X on EKS, I had this issue too. The I manually deleted the NLB that had been created, and then re-ran the |
Hey y'all 👋 Thank you for taking the time to file this issue and the ongoing discussion! Given that there's been a number of AWS provider releases since this was initially filed, can anyone confirm whether you're still experiencing this behavior? |
I still have this behavior
versions
|
Still a problem for me in 2023:
|
Still a problem, even via the AWS CLI and Console I'm not able to destroy them. Because the subnets contain one or more network interfaces, and cannot be deleted until those network interfaces have been deleted. And when I want to delete those network interfaces, I get this error: My workaround apply again and then destroy. |
Just want to add my voice to this issue, I am seeing similar |
Also having this issue. In my case the subnets cannot be deleted because Global Accelerator and Application Load Balancer ENIs are attached to them. These ENIs are created automatically by AWS. I tried making the Global Accelerator depend on the subnets that are being destroyed so that TF also destroys the Global Accelerator, and thus hopefully also the attached ENIs, but this doesn't work either (the plan output doesn't indicate that the Global Accelerator will be destroyed). |
Having the same issue. In my case Terraform-created subnets cannot be deleted by Terraform due to AWS-created GuardDuty endpoints |
Hi everyone, Thank you to everyone who's participated in this discussion. This issue has become a bit of a grab bag of issues related to deleting a subnet when it has EC2 instances or ENIs attached to it. In essence, a subnet cannot be deleted while it has instances or ENIs attached, either using Terraform or the AWS Console. @bflad's comment (#9495 (comment)) gives good advice on troubleshooting which ENIs are still attached. Since this issue was opened, we have added special handling code to handle a number of ENI types that are not immediately cleaned up when the associated resource is deleted, including Lambdas, Comprehend, and DMS. There may be others that are now lingering that we're not handling in the provider. In the originally reported issue, a subnet was in use by the autoscaling group and it was then removed from the configuration. If the subnet had been directly assigned to the ASG instead of being assigned via the data source, Terraform would have been aware of the association and should have handled removal appropriately. Unfortunately, there is no way to address this the way that the OP's configuration was written. It seems like some of the other commenters are similarly trying to delete only the subnet without first removing the resources attached to the subnet. This won't work in either Terraform or the AWS Console. For other commenters, we'll need more information so that we can look into the problem that you're having. I'm going to close this issue so that we can focus specifically on individual problems instead of one issue that tries to capture all problems with deleting a subnet. If you're encountering this problem, please open a new issue. If you'd like, can reference this issue from the new issue to link them together. In your new issue, please include:
|
Warning This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them. Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed. |
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. |
Community Note
Terraform Version
Terraform v0.12.5
Terraform Configuration Files
I've truncated some pieces of my configuration to the bare minimum. I later add ECS task definitions and services onto the AWS ECS but I don't think these are important for the issue. I might as well launch them using the AWS console and not with Terraform and I assume the effect will be the same.
Debug Output
After 19 minutes. The subnet is still not destroyed.
Expected Behavior
subnet1 is destroyed
Actual Behavior
Destroying subnet1 hangs. If I attempt to manually remove the resource from the AWS console, I get this:
I assume this is the same reason why Terraform fails to delete the subnet and hangs.
Steps to Reproduce
terraform apply
Important Factoids
I removed the "subnet1" definition from my terraform files and added another subnet definition, causing "subnet1" to be marked for destruction. On my attempt to "apply" the changes, I encountered this hang in deletion.
The text was updated successfully, but these errors were encountered: