aws-cloudformation / aws-cloudformation/cloudformation-coverage-roadmap

Conditional DeletionPolicy

Open
#1,597 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
No language data
Stars
1.1k
Forks
62
PR merge metrics
No merged PRs in 30d

Description

### Name of the resource

Other

### Resource name

Multiple

### Description

Currently the DeletionPolicy of cloudformation resources can be assigned a value from the list:
* Delete
* Retain
* Snapshot (for the resources which support it)

We not too infrequently run into issues with resources that generally need to be marked as Retain, because they will fail to delete under various circumstances, for example an S3 Bucket or an ECR Repository that is not empty can not be deleted by CloudFormation and/or we want to retain any data/content, but don't care about the resource in it's own right.

It would help, particularly in the case of rollbacks if there was a way to make the Deletion policy conditional - that is a DeletionPolicy value that effectively means "delete this resource if you can, but don't error and just retain it if you can't"

For example, perhaps something like
```
DeletionPolicy: DeleteIfEmpty
```
Which would indicate that a resource can be removed if it has no content or other configuration (eg for an S3 bucket whether there are any objects present, for an ECR Repository whether there are any images etc) that would prevent it's removal, but that it's ok to leave behind if it does.

### Other Details

_No response_

Contributor guide

Open the contributing guide

Research direction

No files, tests, or entry points are mentioned. Start by reviewing how CloudFormation currently handles DeletionPolicy values and rollback failures for non-empty resources such as S3 buckets and ECR repositories. Done means the conditional deletion behavior is designed, implemented, and verified for the described retention cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
infrastructure
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.