terraform-provider-aws: aws_volume_attachment Error waiting for Volume
Terraform Version
Terraform v0.11.7
- provider.aws v1.20.0
Affected Resource(s)
aws_volume_attachment
Actual Behavior
When running a terraform destroy, in which you want to destroy an aws_instance and it’s aws_volume_attachment, terraform (or the AWS API) will attempt to destroy the volume attachment first, then then instance second. This often fails because Error waiting for Volume (vol-010b3d979b1027867) to detach from Instance.
Expected Behavior
If an aws_volume_attachment was going to be destroyed, and the associated aws_instance was also going to be destroyed, it would make sense to destroy the instance first and then the aws_volume_attachment second, which would never run any risk of timing out.
Steps to Reproduce
- Create an
aws_ebs_volume, anaws_instance, and aaws_volume_attachment. terraform destroy
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 80
- Comments: 33 (1 by maintainers)
Commits related to this issue
- Remove `local-exec` to terminate EC2 instances This logic was used to ensure that the EC2 instance for an AWS EBS volume attachment was in a terminated state so that the volume attachment could be de... — committed to cisagov/cyhy_amis by mcdonnnj 3 years ago
- Add option to stop an instance before trying to remove an attached volume By stopping the instance, the volume is unmounted in the instance and the detaching of the volume doesn't run into a timeout ... — committed to hashicorp/terraform-provider-aws by f3lang 5 years ago
Same problem here. Only been a bug 19 months. Could we get Terraform to STOP instances with attached storage, DETACH/DELETE all volumes and then TERMINATE the instance? Seems like a fundamental function fails often in this circumstance.
Same issue for me
Facing the same issue here, we worked around it by including
skip_destroy = truein resourceaws_volume_attachment.According to the documentation, setting
skip_destroy = truewill remove resourceaws_volume_attachmentfrom the state file, and this will unblockterraform destroyoperation.If we’re listing workarounds, shutting down the instance before the destroy will work as well. The detach will work since the volume would not be “busy” at that point.
persists in
+1 here Terraform version: 0.12.25 AWS Provider version: 2.65.0
Even I’m facing this issue.
Terraform v0.12.1