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개 답변
0
수락된 답변

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.

답변함 8달 전
profile picture
전문가
검토됨 5달 전
  • Thank you, I pretty much end up doing the thing you suggested

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠