r/aws_instance: prevent destroy if disable_api_termination is enabled#43722
Conversation
Community GuidelinesThis comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀 Voting for Prioritization
Pull Request Authors
|
% make testacc TESTARGS='-run=TestAccEC2Instance_disableAPITerminationFinal\|TestAccEC2Instance_basic\|TestAccEC2Instance_disappears\|TestAccEC2Instance_disableAPIStop' PKG=ec2
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.24.5 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run=TestAccEC2Instance_disableAPITerminationFinal\|TestAccEC2Instance_basic\|TestAccEC2Instance_disappears\|TestAccEC2Instance_disableAPIStop -timeout 360m -vet=off
2025/08/06 10:22:55 Creating Terraform AWS Provider (SDKv2-style)...
2025/08/06 10:22:55 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccEC2Instance_basic
=== PAUSE TestAccEC2Instance_basic
=== RUN TestAccEC2Instance_disappears
=== PAUSE TestAccEC2Instance_disappears
=== RUN TestAccEC2Instance_disableAPIStop
=== PAUSE TestAccEC2Instance_disableAPIStop
=== RUN TestAccEC2Instance_disableAPITerminationFinalFalse
=== PAUSE TestAccEC2Instance_disableAPITerminationFinalFalse
=== RUN TestAccEC2Instance_disableAPITerminationFinalTrue
=== PAUSE TestAccEC2Instance_disableAPITerminationFinalTrue
=== RUN TestAccEC2Instance_basicWithSpot
=== PAUSE TestAccEC2Instance_basicWithSpot
=== CONT TestAccEC2Instance_basic
=== CONT TestAccEC2Instance_disableAPITerminationFinalFalse
=== CONT TestAccEC2Instance_basicWithSpot
=== CONT TestAccEC2Instance_disableAPITerminationFinalTrue
=== CONT TestAccEC2Instance_disableAPIStop
=== CONT TestAccEC2Instance_disappears
--- PASS: TestAccEC2Instance_disappears (57.70s)
--- PASS: TestAccEC2Instance_basic (72.62s)
--- PASS: TestAccEC2Instance_disableAPITerminationFinalFalse (93.50s)
--- PASS: TestAccEC2Instance_disableAPITerminationFinalTrue (97.58s)
--- PASS: TestAccEC2Instance_basicWithSpot (106.21s)
--- PASS: TestAccEC2Instance_disableAPIStop (108.64s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/ec2 115.340s |
d0a1390 to
dee4289
Compare
|
Warning This Issue has been closed, meaning that any additional comments are much easier for the maintainers to miss. Please assume that the maintainers will not see them. Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed. |
|
This functionality has been released in v6.8.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
|
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the library.
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
Description
When
disable_api_terminationis enabled terraform should fail to destroy the resource.This PR prevents destruction of a resource with this enabled
force_destroyto enable destroying an instance that hasdisable_api_terminationenabled.Relations
References
Output from Acceptance Testing