aws / aws/aws-sam-cli

Feature request: add hook(s) for cleaning up CF empty changesets

Open
#4,113 14 comments 4 reactions 0 assignees View on GitHub
area/deploy type/feature
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### Describe your idea/feature/enhancement

Provide a clear description. Ex. I wish SAM CLI would [...]

I wish SAM CLI would provide a sub command (and or transparent option) to have changesets which are ignored do to nothing changes which the user chooses ignore with `--no-execute-changeset` to clean up unapplied changesets

I've found in a few continuous deployment cases were I have `--no-execute-changeset` where I preview deployment with other applying as well as run deploy ignoring empty changesets with `fail_on_empty_changeset` set to false but these changesets accumulate and eventually lead to an error when the stack hits a cloud formation limit

I have a work around in the form of a custom script

```
for name in $(
aws cloudformation list-change-sets --stack-name ${STACK_NAME} --output text --query "Summaries[?StatusReason=='The submitted information didn\'t contain changes. Submit different information to create a change set.'].ChangeSetName"
); do
echo "deleting changeset $name"
aws cloudformation delete-change-set --stack-name ${STACK_NAME} --change-set-name $name;
done
```

I'd like something like this to be built-in and in the most ideal situations automatically delete an unapplied changeset when an deploy fails do to an empty changeset so I don't even have to think about it

### Proposal

Add details of how to add this to the product.

either add a new subcommand do to this in masse, or an flag `deploy` to opt in or just do this automatically. I believe sam already knows when its an empty changeset error ie. the `fail_on_empty_changeset` hook.

Things to consider:
1. Will this require any updates to the [SAM Spec](https://github.com/awslabs/serverless-application-model)

nope

### Additional Details

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.