Closed kenlee0305 closed 6 months ago
Hi @kenlee0305
I trust you are well. I will try my best to answer your questions.
But CloudFormation can not detect any changes due to the file is a zip file.
This observation is correct. As mentioned in the AWS::Lambda::Function Code documentation:
Changes to a deployment package in Amazon S3 are not detected automatically during stack updates. To update the function code, change the object key or version in the template.
Therefore, to answer your first question:
How to update Lambda function using CloudFormation template
CodeUri
sectionRegarding your second question:
Should I use AWS::Lambda::Function or AWS::Serverless::Function resources? I want to have version control supported.
I think this is dependent on the wider problem you are trying to solve with your Cloudformation stack. Personally I enjoying using the AWS SAM framework because:
sam init
you can get started with new templated projects quite rapidlysam deploy
Regarding version control, choose a repo provider (e.g. GitHub, AWS CodeCommit, etc) upload your lambda code and the SAM template. For example, you could then make use of GitHub Actions or CodeBuild to deploy your lambda (via SAM deploy) to your respective AWS account(s).
All the best.
Closing this issue or pull request in advance of archiving this repo. For more information about the decision to archive this repo (and others in the 'awsdocs' org), see the announcement on the AWS News Blog.
I want to deploy and update Lambda function using CloudFormation stacks.
My Stack creation workflows are:
However, I have no idea how to update the Lambda function using the template. I have tried to upload the new function code to S3 and save as a new file name. And use the new file as parameters to update stacks. But CloudFormation can not detect any changes due to the file is a zip file.
My questions:
AWS::Lambda::Function
orAWS::Serverless::Function
resources? I want to have version control supported.Thank you.
My CloudFormation template is as below.