kumar
kumar

Reputation: 9427

AWS Lambda SAM rollback deployment

Once a lambda is deploy and incase it has some bad logic in it, using aws Lambda SAM is there a way to rollback deployment?

Upvotes: 3

Views: 4073

Answers (2)

rainabba
rainabba

Reputation: 4287

As of 2021-06-22, there isn't a cli method to "roll-back" a sam deploy stack. There is an open issue about it here.

At the moment, my solution is to ensure that I'm doing a proper release in Git, then I can checkout any previous version, build and deploy (updating the live stack accordingly, not rolling-back per-se.)

Because sam deploy is ultimately doing a cloudformation deploy, failure/rollback is always a possibility at the stack level. That also means that you can use aws cli to investigate and manipulate stack deployed via SAM just like any other.

Upvotes: 0

me2resh
me2resh

Reputation: 886

If you want to rollback to a previous version of the lambda

You can publish a new version of your lambda every time you deploy using sam cli. if you add the "AutoPublishAlias" property to your lambda function.

Example:

  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: cmd/lambdas/hello-world/app.lambdaHandler
      CodeUri: src/
      Runtime: nodejs12.x
      AutoPublishAlias: live
      Events:
        CatchAll:
          Type: Api
          Properties:
            Path: /hello-world
            Method: GET

Then anytime you want to rollback you can pick a previous version from the interface enter image description here

Upvotes: 3

Related Questions