问题
I have a cloudformation stack template that includes regional resources (lambdas, api, topics, etc.) and global resources (user, policies, route53, cloudfront, dynamodb global tables, etc.) and want to deploy it to multiple region in the same AWS account.
I can't directly deploy this stack template in multiple region because global resources will already exist after the first creation.
I know I could split everything in two separate stack templates but I would prefer to avoid this and keep everything in the same single stack template.
I saw that I could probably use CF Conditions + Parameters to toggle global resource creation only on first creation but that doesn't look very good...
I was wondering if I could leverage some CloudFormation feature like StackSets or something else to achieve that.
Any idea on what would be the proper way to do this?
回答1:
The solution is at your hands. I suggest that you do the following:
- Create a separate template for the global resources (yes, I know that you don't like it, but it works well in my experience)
- Store references to the shared global resources in SSM using AWS::SSM::Parameter
- Deploy regional stacks and de-reference the global resources (either using Parameters, such as the
AWS::SSM::Parameter::Value<String>
or dynamic reference, e.g.{{resolve:ssm:S3AccessControl:2}}
)
You can use either StackSets
for your regional stack deployments or create a parameterized build script that deploys the regional stacks one at the time (to be executed either locally or preferably by your CI/CD server).
来源:https://stackoverflow.com/questions/53634750/what-is-the-proper-way-to-deploy-a-multi-region-cloudformation-stack-that-includ