1
votes

In my CodePipeline, I am creating a CloudFormation ChangeSet and then executing it to deploy Lambda functions. It doesn't seem like CloudFormation saves the old ChangeSets so that I can revert to an old version. Am I wrong?

CloudFormation does automatically rollback when it fails to create/execute the ChangeSet due to IAM permission issues and such but I want the ability to manually rollback in case I deploy a buggy function.

1
in my opinion, you are using the wrong approach. you should really have integration tests to check for iam permissions because you'll need to exercise multiple logic flows in your function that may use different permissions. Another difficulty that you will run into is to how to separate iam permission errors from other runtime errors that you might already have since previous deployments. The question is: is it worth it?Jeshan

1 Answers

1
votes

You could use rollback triggers in AWS CloudFormation to detect failed tests in your code, via Amazon CloudWatch metrics and alarms, and perform an automated rollback.

Your application code would need to be modified to perform the tests upon deployment, and then write the metric values into Amazon CloudWatch.

There are a couple limits you'll want to be aware of:

  • Maximum of five (5) rollback configurations per CloudFormation stack
  • Monitoring time: 0 - 180 minutes (3 hours)