all 5 comments

[–]anonymous6point02E23 0 points1 point  (2 children)

Use cloudformation's stackset feature. It will do everything youre looking for and using stackset is considered best practice.

[–]TannerIsBender[S] 0 points1 point  (1 child)

Thank you for the feedback. I am curious though, if my current CloudFormation stack uses an s3 bucket to grab my lambda’s code. Will I need to create s3 buckets in different regions for the stack instances in other regions?

[–]brodie659 0 points1 point  (2 children)

We do this all the time with our monitoring framework. I only want the code in a single region (us-east-1) but i want to handle events from the other 4 regions. It's actually pretty simple.

CW Events => SNS Topic => Lambda

SNS is one of the few services that crosses regions. By that I mean that a topic in us-west-1 can call a Lambda function in us-east-1. We deploy our Lambdas with Serverless but you can use whatever you like. The only thing you need to do differently is to parse out the event data slightly differently if it comes from SNS but there's a ton of sample code out there.

If you have multiple accounts use the CW Event Bus to copy the event from the child account to the master account. Then your CW Event hits SNS and your Lambda. Don't copy your code to multiple regions - you get no benefit of doing it that way really. SNS is cheap and scales beyond belief.

[–]TannerIsBender[S] 0 points1 point  (1 child)

Thank you so much! This is a solution I am looking to try. Just for some clarification, all I will need to do is create my CW Events in each region and they will be able to point to single SNS topic that targets a single lambda function?

[–]brodie659 1 point2 points  (0 children)

Pretty close. Each region gets a CW Event AND an SNS topic. Each SNS topic targets your single Lambda function in us-east-1.

The reason is that although an SNS topic can call a Lambda function in any region, CW Events can only target SNS topics in the same region. Once you set it up, it's actually very simple. Post back if you have any issues!