How to create a new version of a Lambda function using CloudFormation?

后端 未结 11 654
清歌不尽
清歌不尽 2020-12-08 03:44

I\'m trying to create a new version of a Lambda function using CloudFormation.

I want to have multiple versions of the same Lambda function so that I can (a) point a

11条回答
  •  抹茶落季
    2020-12-08 04:44

    This post is out-of-date. I am updating it here so others can see the correct solution for versioning Lambdas as of 06-09-2020, without the need for extra custom versioning Lambdas.

    This:

    Description: Lambda Example
    Resources:
      Function:
        Type: AWS::Lambda::Function
        Properties:
          Handler: index.handler
          Code:
            ZipFile: |
              'Example Code';
          Runtime: nodejs12.x
          Timeout: 5
    

    Becomes this:

    Description: Lambda Example
    Transform: AWS::Serverless-2016-10-31
    Resources:
      Function:
        Type: AWS::Serverless::Function
        Properties:
          AutoPublishAlias: live
          Handler: index.handler
          InlineCode: |
            'Example Code';
          Runtime: nodejs12.x
          Timeout: 5
    

    The Transform: allows AWS::Serverless::Function inside of a CloudFormation template which in turn supports lambda versioning.

    Don't let the dated "Best Answer" above - built for that persons book - throw you down a rabbit hole like I did.

    You're welcome.

提交回复
热议问题