-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Have Terraform stop to-be-destroyed instance first when moving attached ebs volume #2084
Comments
There are a bunch of tickets about this problem: The problem seems to be that the EBS volume is being detached from an EC2 instance, while it's still mounted. Shutting down the EC2 instance first is probably the only sane thing to do in general. I can do that by adding a destroy-provisioner to the EBS-attachment: provisioner "remote-exec" {
when = "destroy"
inline = "sudo poweroff"
} But there's no way to start the instance again. So when changing the attachment of an EC2 instance from EBS volume A to volume B I then get this error:
Not sure how the terraform provider could handle this. #569 suggests to add a new Probably best would be if terraform-aws would stop the instance before detaching, and start the instance again before attaching, both using the AWS APIs. |
My eventual solution, but only works for us because the instance and volume are both ephemeral and will always be created/destroyed together.
|
@duality72 can I use your solution for instances in |
@GarrisonD very late reply here, but I don't see why not |
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you! |
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! |
When destroying an instance, and then moving an attached volume to another instance, it would be nice if Terraform could send a Stop to the instance being destroyed first.
This is because often the volume doesn't detach in time and I end up just stopping the old instance and re-running the apply. The old instance is getting destroyed anyway.
Terraform Version
10.7 and before
Affected Resource(s)
Please list the resources as a list, for example:
volume_attachment
Panic Output
1 error(s) occurred:
module.sre_apps.aws_volume_attachment.az1_collector_data (destroy): 1 error(s) occurred:
aws_volume_attachment.az1_collector_data: Error waiting for Volume (vol-0ec7ae950309d165a) to detach from Instance: i-058b7f34f0a545f77
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
Expected Behavior
Volume moves to other instance quickly
Actual Behavior
What actually happened?
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
The text was updated successfully, but these errors were encountered: