fix: allow stopping instance before detachment and/or forced ebs detachments #212
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added support to the EBS volume attachment resource for the
force_detach
andstop_instance_before_detaching
arguments.These changes allow users to:
- Force the detachment of EBS volumes.
- Stop instances before detaching volumes, ensuring smooth resource teardown during Terraform destroy operations.
why
I cannot delete my Terraform resources using a standard Terraform destroy because I have attached additional ebs volumes to my instance and then ran disk configuration changes in my instance, for example, combined multiple ebs volumes into a striped disk config.
Business use cases may require additional EBS volumes, along with specific disk configurations for the volumes attached to EC2 instances.
When attempting to delete resources via Terraform, the destroy process fails due to issues with EBS volume attachments. These issues include timeouts or the inability to delete volumes because they are in a "busy" state.
The problem arises because Terraform attempts to detach EBS volumes before deleting/stopping the EC2 instance, leading to failures if the volume cannot be detached.
To address this, Terraform introduced the
force_detach
andstop_instance_before_detaching
arguments, which allows forced detachment and/or stopping of the instance prior to detaching volumes. These enhancements mitigate the destroy-time failures and ensure smoother resource cleanup.references
The
force_detach
andstop_instance_before_detaching
arguments were introduced in Terraform AWS provider version v3.62.0.Additional details and discussion about this issue can be found in this GitHub thread.