I want to deploy and update my lambda function code using CloudFormation Template.
My deployment workflow are:
- Compress my lambda function code into a zip file called
Lambda
- Enabling s3 versioning of the s3 bucket called
LambdaS3
- Upload the zip file into s3 bucket called
LambdaS3
- Upload the CloudFormation template
CFtemplate
as below into the s3bucketLambdaS3
- Create the CloudFormation stack by entering "LambdaS3" as parameter
LambdaS3
, "Lambda" as parameterLambdafilename
and the version of the zip file as the parameterLambdafileVersion
My lambda code update workflow are:
- Compress my updated lambda function code into a zip file called
Lambda
- Upload the updated zip file into the s3 bucket called
LambdaS3
- Update the CloudFormation stack by entering the updated version of the zip file as the parameter
LambdafileVersion
- What I expected: deployment and update will be successful
- Actual result: Get the message from AWS "There was an error creating this change set The submitted information didn't contain changes. Submit different information to create a change set." during updating the stack, while deployment is successful.
My template is as below
AWSTemplateFormatVersion: "2010-09-09"
Metadata: ""
Description: ""
Parameters:
LambdaS3:
Description: Api Gateway Authorizer Lambda S3Bucket Name
Type: String
Lambdafilename:
Description: Api Gateway Authorizer Lambda file Name (Latest)
Type: String
LambdafileVersion:
Description: Lambda zip file version
Type: String
Transform: AWS::Serverless-2016-10-31
Resources:
LambdaFunction:
DeletionPolicy: "Delete"
Type: "AWS::Serverless::Function"
Properties:
Description: ""
FunctionName: "LambdaFunction"
Handler: "lambda_function.lambda_handler"
CodeUri:
Bucket: !Ref LambdaS3
Key: !Sub '${Lambdafilename}.zip'
Version: !Ref LambdafileVersion
MemorySize: 512
Role: !GetAtt IAMRole2.Arn
Runtime: "python3.8"
Timeout: 20
Tracing: "PassThrough"
AutoPublishAlias: live
DeploymentPreference:
Type: Linear10PercentEvery10Minutes
CodePudding user response:
This does not work because you are using CodeDeploy. If you want to update functions they way you are trying, then you have to remove the following from your code:
AutoPublishAlias: live
DeploymentPreference:
Type: Linear10PercentEvery10Minutes