deploy AWS lambda function to multiple regions with CICD

0

Hi,

My goal: I want to deploy a lambda function to 6 different regions, and I will only use AWS cron job to trigger the function. And I also want to when I update my lambda function, all 6 regions with my lambda function will also got update which is auto deploy the new code I just wrote. And, also if I want to change the AWS cron job time interval for 6 regions to trigger the function, is there a way I can change the time in one place and all 6 region corn job got update. Also, If I want to change one region to another new region, is there a easy way for me to achieve?

I am ok to use any solution such as any tool with UI or else to achieve my goal above. Currently, I have found that AWS CDK can achieve something like that, but not sure if it can 100% achieve my goal above. Could anyone help me out?

1 Answer
0
Accepted Answer

Hello,

I think aws S3 + CodePipeline + Cloudformation can help you solve this problem.

You can upload the updated lambda code to aws s3 and set it as the trigger source of CodePipeline, copy this source file to the s3 bucket of all Regions you need, and then use the code files of each region to execute in CodePipeline Cross-region cloud formation deployment.

Here is a guide from AWS about multi-region deployment that I think you can refer to.

In addition, based on my previous experience of using CodePipeline to deploy lambda, if the file URL deployed each time is the same, cloudformation will not update the lambda code.

To solve this problem you need to use the aws sam template instead of the cloudformation template. Specify AutoPublishAlias ​​and AutoPublishCodeSha256 for AWS::Serverless::Function in the sam template. You need to provide a unique AutoPublishCodeSha256 for each deployment.

If you want to change regions, please directly change the codepipeline configuration, but the deployed cloudformation stack may remain in the old region.

answered 10 months ago
profile picture
EXPERT
reviewed 7 months ago
  • Thank you, I pretty much end up doing the thing you suggested

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions