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

Terraform is not removing tainted aws_resource and it's failing to remove aws_volume_attachment #9065

Closed
hgontijo opened this issue Sep 26, 2016 · 2 comments

Comments

@hgontijo
Copy link
Contributor

Terraform Version

0.7.4

Affected Resource(s)

  • aws_volume_attachment
  • aws_instance

Terraform Configuration Files

resource "aws_instance" "teamcity_server" {
  ami = "${var.server_ami}"
  availability_zone = "${var.server_az}"
  instance_type = "${var.server_instance_type}"
  vpc_security_group_ids = [ "${split(",", var.security_groups)}" ]
  subnet_id = "${var.subnet_id}"

  key_name = "${var.key_name}"
  iam_instance_profile = "tc-server"

  root_block_device {
    volume_type = "gp2"
  }
}

resource "aws_ebs_volume" "data_volume" {
  availability_zone = "${var.server_az}"
  snapshot_id = "${var.data_volume_snapshot}"
  size = "${var.data_volume_size}"
  type = "gp2"
}

resource "aws_volume_attachment" "data_volume_attachment" {
  device_name = "/dev/sdf"
  instance_id = "${aws_instance.teamcity_server.id}"
  volume_id = "${aws_ebs_volume.data_volume.id}"
}

I ommited non-relevant parts.

Expected Behavior

Since the aws_instance has an aws_volume_attachment, we used to taint aws_instance before running terraform destroy to ensure the instance is marked for deletion so that aws_instance, aws_volume_attachment, aws_ebs_volume are properly destroyed regardless of the volume attachment dependency. This was working fine until v0.6.16.

Actual Behavior

$ terraform taint -no-color -allow-missing -module=teamcity aws_instance.teamcity_server
The resource aws_instance.teamcity_server in the module root.teamcity has been marked as tainted!
$ terraform destroy
...
Error applying plan:

1 error(s) occurred:

* aws_volume_attachment.data_volume_attachment: Error waiting for Volume (vol-af94311b) to detach from Instance: i-a6182dbe

Full logs

Based on the logs, aws_instance is not being removed as expected by running taint before destroy.

Steps to Reproduce

  1. terraform apply
  2. `terraform taint -no-color -allow-missing -module=teamcity aws_instance.teamcity_server``
  3. terraform destroy

References

That maybe related to:

@kshcherban
Copy link

Same issue with 0.7.10
Seems like before detaching instance should be stopped.

@ghost
Copy link

ghost commented Apr 10, 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 Apr 10, 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

4 participants