Categories
AWS Cloud Computing

Fixing an error occurred (LimitExceededException) when calling the CreateChangeSet operation

CloudFormation change sets allow you to preview how proposed changes might impact your resources. In certain scenarios these changes will pile up rendering an error as there are limits on the amount of change sets that you can have for a particular stack.

CloudFormation change sets allow you to preview how proposed changes might impact your resources. In certain scenarios these changes will pile up rendering an error as there are limits on the amount of change sets that you can have for a particular stack. Last time I contacted AWS support the limit was 1000 change sets.

This problem has been discussed before, you can read more about it here:

https://github.com/cloudtools/stacker/issues/508

https://github.com/serverless/serverless/issues/149

The solution is to create a script and clean all the change sets at once like it was done here:

https://cloudonaut.io/aws-cli-cloudformation-deploy-limit-exceeded/

I took that script and made it simpler as I already knew the offending stack in my setup. Don’t forget to replace YOUR_STACK_NAME (to whatever you named it of course) and YOUR_REGION (for example eu-central-1):

#!/bin/bash
cleanup() {
  changesets=$(aws cloudformation list-change-sets --stack-name YOUR_STACK_NAME --query 'Summaries[?Status==`FAILED`].ChangeSetId' --output text --region YOUR_REGION)
  for changeset in $changesets
    do
      echo "${stack}: deleting change set ${changeset}"
      aws cloudformation delete-change-set --change-set-name ${changeset} --region YOUR_REGION
    done
}
cleanup

Have your AWS CLI properly configured, save that script and run it like this.

bash /path/to/scriptname

Leave a comment

Design a site like this with WordPress.com
Get started