英文:
How to create multiple cloudformation stacks where a single parameter changes?
问题
我想将城市列表作为参数输入到 SAM 模板中。例如:伦敦、纽约、迪拜。列表可能包含大量城市,比如说 50 个。
使用这个城市列表,我想为每个城市创建一个相应的日志组。例如:
- /aws/ecs/迪拜
- /aws/ecs/伦敦
- /aws/ecs/纽约
我该如何实现这个?
英文:
I want to enter a list of cities as parameters to a SAM template. For Example: London, New York, Dubai. The list can have a large number of cities, say 50.
Using this list of cities, I want to create a log group pertaining to each city. For example:
- /aws/ecs/Dubai
- /aws/ecs/London
- /aws/ecs/New York
How can I achieve this?
答案1
得分: 2
你可以在Cloudformation中使用Count Macro。
AWSTemplateFormatVersion: "2010-09-09"
Transform: Count
Resources:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: /aws/ecs/%s
Count: ['Dubai','London','NewYork']
更多信息请查看此问题:https://stackoverflow.com/questions/57195157/how-to-loop-through-values-in-a-cloudformation-template
英文:
You can use Count Macro in Cloudformation.
AWSTemplateFormatVersion: "2010-09-09"
Transform: Count
Resources:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: /aws/ecs/%s
Count: ['Dubai','London','NewYork']
For more information check this question: https://stackoverflow.com/questions/57195157/how-to-loop-through-values-in-a-cloudformation-template
答案2
得分: 1
我最终在CloudFormation中使用了Explode宏来解决这个问题:
英文:
I eventually used the Explode macro in CloudFormation to solve this problem:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论