在不同区域创建 CloudFormation 资源 [英] Create CloudFormation resources in different region
问题描述
我有一个 CF 堆栈并且我定义了不同的资源.其中之一是 S3 存储桶.我需要在 eu-west-1
区域中运行堆栈,同时在 ap-southeast-1
区域中创建存储桶.我怎么能做这样的事情?
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?
推荐答案
不幸的是,使用 CloudFormation 中的标准 AWS::S3::Bucket
是不可能的,因为由 CloudFormation 堆栈管理的资源只能与堆栈本身位于同一区域.但是,您可以使用 Lambda 函数来解决此问题
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
当 创建存储桶.此外,您的 Lambda 函数将负责更新和删除您的存储桶,这可能涉及更多代码.
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.
您可以使用 Lambda 支持的自定义资源.
这篇关于在不同区域创建 CloudFormation 资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!