Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create CloudFormation resources in different region

I've a CF stack and I've defined different resources. One of these is an S3 Bucket. I need to run the stack in the eu-west-1 region while create the bucket in the ap-southeast-1 region. How can I do something like this?

like image 426
Mazzy Avatar asked Jun 15 '26 21:06

Mazzy


2 Answers

Unfortunately this is impossible using the standard AWS::S3::Bucket in CloudFormation, since resources managed by a CloudFormation stack can only reside in the same region as the stack itself. However, you could work your way around this by using a Lambda function

Your Lambda function would have to set the LocationConstraint to ap-southeast-1 when creating the bucket. Also, you Lambda function will be responsible for updating and deleting your bucket, which can involve a bit more code.

You can wire your Lambda function to CloudFormation using Lambda-backed Custom Resources.

like image 166
spg Avatar answered Jun 17 '26 20:06

spg


A single CloudFormation stack can only have resources in the single region that the stack resides.

However, using CloudFormation Stack Sets, you can create resources across multiple CloudFormation stacks in multiple regions and AWS accounts.

More information about using Stack Sets can be found in the Stack Set documentation: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-concepts.html

like image 43
Matt Houser Avatar answered Jun 17 '26 18:06

Matt Houser