Terraform should have reported that it can't delete the security group because it's currently used by an instance. This is the behavior if you try and delete a security group via console.
Terraform got stuck on attempting to delete the security group.
Create a security group via terraform. Attach the security group to an instance that's not in terraform. Attempt to destroy the security group via terraform.
This also happens if the security group is attached to an instance that IS in terraform, then a change that forces a new resource (e.g. security group description change) is made.
Looks like the resource graph doesn't account for attached resources when destroying a security group. I've had to manually decomission the resources that the SG is attached to first, then run the terraform apply
again.
Is there not something we can add like depends_on = ...
to the resources to update the order in which resources get destroyed?
this issue has been happening since 2016
https://github.com/hashicorp/terraform/issues/8772
Is there a reason why this is not addressed or is just a matter of time?
I just spent 4 hours trying to find out if I had to manage the ELB ENIs on Terraform too :(
I acknowledge that this is a dupe of https://github.com/terraform-providers/terraform-provider-aws/issues/265
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!
Most helpful comment
This also happens if the security group is attached to an instance that IS in terraform, then a change that forces a new resource (e.g. security group description change) is made.