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

Race condition w/ subnet destroy in AWS. #357

Closed
russroy opened this issue Oct 3, 2014 · 7 comments
Closed

Race condition w/ subnet destroy in AWS. #357

russroy opened this issue Oct 3, 2014 · 7 comments

Comments

@russroy
Copy link

russroy commented Oct 3, 2014

I use terraform to create a single instance and subnet resource within AWS. Attempting to destroy though one encounters a failure due to race condition. Destruction needs to happen in a synchronous manner. As it is, terraform correctly destroys the instance before the subnet upon which it is dependent but, in AWS, instance destruction is not instantaneous and subnet deletion fails:

rroy:work-terraform rroy$ terraform show terraform.tfstate
aws_instance.rroy-intc-061600-enchantd-0-0:
  id = i-4c5033a2
  ami = ami-06d3766e
  availability_zone = us-east-1b
  instance_type = t2.micro
  key_name = rroy-aws
  private_dns = ip-100-xxx-xxx-90.ec2.internal
  private_ip = 100.xxx.xxx.90
  public_dns = 
  public_ip = 
  security_groups.# = 1
  security_groups.0 = default
  subnet_id = subnet-00bca728
aws_subnet.rroy-intc-061600-enchantd-0:
  id = subnet-00bca728
  availability_zone = us-east-1b
  cidr_block = 100.xxx.xxx.0/24
  vpc_id = vpc-b8cb36dd

rroy:work-terraform rroy$rroy:work-terraform rroy$ terraform destroy .
aws_subnet.rroy-intc-061600-enchantd-0: Refreshing state... (ID: subnet-00bca728)
aws_instance.rroy-intc-061600-enchantd-0-0: Refreshing state... (ID: i-4c5033a2)
aws_instance.rroy-intc-061600-enchantd-0-0: Destroying...
aws_instance.rroy-intc-061600-enchantd-0-0: Destruction complete
aws_subnet.rroy-intc-061600-enchantd-0: Destroying...
aws_subnet.rroy-intc-061600-enchantd-0: Error: Error deleting subnet: The subnet 'subnet-00bca728' has dependencies and cannot be deleted. (DependencyViolation)
Error applying plan:

1 error(s) occurred:

* 1 error(s) occurred:

* Error deleting subnet: The subnet 'subnet-00bca728' has dependencies and cannot be deleted. (DependencyViolation)

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.

# A minute or so later (once the instance destruction is complete)
# we're able to re-run the same cmd, this time successfully.

rroy:work-terraform rroy$ terraform destroy .
aws_subnet.rroy-intc-061600-enchantd-0: Refreshing state... (ID: subnet-00bca728)
aws_subnet.rroy-intc-061600-enchantd-0: Destroying...
aws_subnet.rroy-intc-061600-enchantd-0: Destruction complete

Apply complete! Resources: 0 added, 0 changed, 1 destroyed.
rroy:work-terraform rroy$ 
@mitchellh
Copy link
Contributor

Thanks! This is fixed in master.

@pmoust
Copy link
Contributor

pmoust commented Oct 3, 2014

@mitchellh I am experiencing the same with terraform just built from master

@armon armon reopened this Oct 4, 2014
@russroy
Copy link
Author

russroy commented Oct 5, 2014

Likewise.

On Fri, Oct 3, 2014 at 5:57 PM, Panagiotis Moustafellos <
[email protected]> wrote:

@mitchellh https://github.com/mitchellh I am experiencing the same with
terraform just built from master


Reply to this email directly or view it on GitHub
#357 (comment).

@mitchellh
Copy link
Contributor

Fixed

@russroy
Copy link
Author

russroy commented Dec 30, 2014

This is broken again (or at least the symptom is the same) in v0.3.6.dev.

@hschaeidt
Copy link

I'm running into the same issue. 0.3.6
This issue can be bypassed in the meantime by calling the terraform destroy twice.

@ghost
Copy link

ghost commented May 4, 2020

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

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

No branches or pull requests

5 participants