aws-cloudformation / aws-cloudformation/cloudformation-coverage-roadmap
[AWS::EC2::Instance] - [Enhancement] - Prevent Resource Duplication When DeletionProtection Is Enabled
- Dominant language
- No language data
- Stars
- 1.1k
- Forks
- 62
- PR merge metrics
- No merged PRs in 30d
Description
### Name of the resource
AWS::EC2::Instance
### Resource name
DeletionProtectionBehaviorOnUpdate
### Description
# Issue Description
When attempting to update an EC2 instance with DeletionProtection enabled via CloudFormation, a new instance is created instead of replacing the existing one. The original instance remains intact, which results in resource duplication and potential cost overruns. This behavior is unexpected and does not align with the typical behavior of CloudFormation updates.
# Expected Behavior
If DeletionProtection is enabled and the update requires the instance to be replaced, the CloudFormation stack update should fail and roll back. This ensures that no new instance is created unless the existing instance can be properly replaced.
# Observed Behavior
During the update process:
A new EC2 instance is created.
The original EC2 instance is retained due to DeletionProtection.
CloudFormation completes the stack update with errors , leaving both the original and new instances active.
# Test Cases
Create an EC2 instance with DeletionProtection enabled via CloudFormation.
Update the instance's ImageId or other attribute that triggers a replacement.
Observe whether a new instance is created and the old instance remains due to DeletionProtection.
### Other Details
・This behavior can cause unexpected costs and complicate resource management.
・It contradicts the principle of stack consistency, where updates should either succeed or roll back.
・Suggested fix: Ensure that when DeletionProtection prevents an instance replacement, the stack update fails and rolls back instead of creating a new instance.
Contributor guide
Research direction
Start by reproducing the listed CloudFormation update against an AWS::EC2::Instance with DeletionProtection enabled, changing ImageId or another replacement-triggering attribute. Confirm whether the original and replacement instances remain and whether the stack reports errors. Done means the update fails and rolls back without creating a duplicate instance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100