Skip to content
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

Destroying resources on AWS fails due to delays in dependency removal #276

Closed
arnuschky opened this issue Sep 9, 2014 · 7 comments
Closed

Comments

@arnuschky
Copy link

Destroying resources on AWS often fails due to delays in the removal of dependent resources.

For example, when removing security groups, terraform often fails because the dependent instances haven't yet been fully removed: even though terraform initiated the removal in correct order, the operation takes a while to complete.

Accordingly the second destroy run always completes successfully.

Same happens with other resources that depend on slow operations, eg vpcs or subnets.

@arnuschky
Copy link
Author

Using 0.2.1

@mitchellh
Copy link
Contributor

We should be waiting for the resources to clean up, but I'll take a look. You said instances are an issue. Any other specific cases?

@arnuschky
Copy link
Author

Some output:

$ terraform apply destroy.tfplan
aws_instance.a: Destroying...
aws_instance.b: Destroying...
aws_instance.c: Destroying...
aws_internet_gateway.gw: Destroying...
aws_eip.main: Destroying...
aws_eip.main: Error: Address xx.xx.xx.xx is in use. (InvalidIPAddress.InUse)
aws_internet_gateway.gw: Error: Network vpc-xxxxx has some mapped public address(es). Please unmap those public address(es) before detaching the gateway. (DependencyViolation)
aws_instance.a: Destruction complete
aws_instance.c: Destruction complete
aws_instance.b: Destruction complete
Error applying plan:

1 error(s) occurred:

* Address xx.xx.xx.xx is in use. (InvalidIPAddress.InUse)

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

On a second run, all the remaining resources get destroyed.

@mitchellh
Copy link
Contributor

Thanks, I'm working through this now.

@mitchellh
Copy link
Contributor

So the provider does wait until AWS is reporting that the instance is in the "terminated" state, so I'm just going to add retry logic to the EIP destroy.

@mitchellh
Copy link
Contributor

Fixed

@arnuschky
Copy link
Author

Awesome, that was fast. Thanks a lot!

@ghost ghost locked and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants