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

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则