-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
provider/aws: Succeed creating aws_volume_attachment if identical attachment exists #11060
provider/aws: Succeed creating aws_volume_attachment if identical attachment exists #11060
Conversation
If an `aws_volume_attachment` is identical to one that already exists in the API, don't attempt to re-create it (which fails), simply act as though the creation command had already been run and continue. This allows Terraform to cleanly recover from a situation where a volume attachment action hangs indefinitely, possibly due to a bad instance state, requiring manual intervention such as an instance reboot. In such a situation, Terraform believes the attachment has failed, when in fact it succeeded after the timeout had expired. On the subsequent retry run, attempting to re-create the attachment will fail outright, due to the AttachVolume API call being non-idempotent. This patch implements the idempotency client-side by matching the (name, vID, iID) tuple. Note that volume attachments are not assigned an ID by the API.
Hi @dougneal Thanks so much for this - this actually solves another issue as well that I had just started looking at :) 3 instances, each with a volume attached. When i tainted an instance and ran terraform apply, I got this
With this code fix, I was able to successfully get it running:
|
…#11060) If an `aws_volume_attachment` is identical to one that already exists in the API, don't attempt to re-create it (which fails), simply act as though the creation command had already been run and continue. This allows Terraform to cleanly recover from a situation where a volume attachment action hangs indefinitely, possibly due to a bad instance state, requiring manual intervention such as an instance reboot. In such a situation, Terraform believes the attachment has failed, when in fact it succeeded after the timeout had expired. On the subsequent retry run, attempting to re-create the attachment will fail outright, due to the AttachVolume API call being non-idempotent. This patch implements the idempotency client-side by matching the (name, vID, iID) tuple. Note that volume attachments are not assigned an ID by the API.
Nice :) |
…hashicorp#11060) If an `aws_volume_attachment` is identical to one that already exists in the API, don't attempt to re-create it (which fails), simply act as though the creation command had already been run and continue. This allows Terraform to cleanly recover from a situation where a volume attachment action hangs indefinitely, possibly due to a bad instance state, requiring manual intervention such as an instance reboot. In such a situation, Terraform believes the attachment has failed, when in fact it succeeded after the timeout had expired. On the subsequent retry run, attempting to re-create the attachment will fail outright, due to the AttachVolume API call being non-idempotent. This patch implements the idempotency client-side by matching the (name, vID, iID) tuple. Note that volume attachments are not assigned an ID by the API.
I used to edit my `tfstate` file manually to import `aws_volume_attachment`. Then I found hashicorp/terraform#11060 which changed Terraform behaviour when an EBS volume is already attached to an instance. I thought would be a good idea to mention it in the docs.
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. |
If an
aws_volume_attachment
is identical to one that already exists in the API, don't attempt to re-create it (which fails), simply act as though the creation command had already been run and continue.This allows Terraform to cleanly recover from a situation where a volume attachment action hangs indefinitely, possibly due to a bad instance state, requiring manual intervention such as an instance reboot. In such a situation, Terraform believes the attachment has failed, when in fact
it succeeded after the timeout had expired. On the subsequent retry run, attempting to re-create the attachment will fail outright, due to the
AttachVolume
API call being non-idempotent. This patch implements the idempotency client-side by matching the(name, vID, iID)
tuple.Note that volume attachments are not assigned an ID by the API.
Addresses #8458