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

后端 未结 11 653
清歌不尽
清歌不尽 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:40

    1. We can make a Lambda deployment package;
    2. Pass the Lambda package with the version as one of Cloud Formation parameters, e.g. "LambdaPakcageNameWithVersion";
    3. Use "LambdaPakcageNameWithVersion" as the Lambda code s3 key;
    4. The new Lamdba package will be deployed when running the aws-cli command to update the cloudformation stack or running CI/CD pipeline.

      MyLambda:
        Type: AWS::Lambda::Function
        Properties:
          Role: LambdaRole
          Code:
            S3Bucket: LambdaPackageS3Bucket
            S3Key: !Sub "${LambdaPakcageNameWithVersion}"
          FunctionName: LambdaFunctionName
          Handler: lambda_function.lambda_handler
          Runtime: python3.6
          Timeout: 60

提交回复
热议问题