![AWS CloudFormation 模板 - 动态添加同一对象的多个实例](https://linux22.com/image/766462/AWS%20CloudFormation%20%E6%A8%A1%E6%9D%BF%20-%20%E5%8A%A8%E6%80%81%E6%B7%BB%E5%8A%A0%E5%90%8C%E4%B8%80%E5%AF%B9%E8%B1%A1%E7%9A%84%E5%A4%9A%E4%B8%AA%E5%AE%9E%E4%BE%8B.png)
答案1
我只会进行全球性调查,因为您未使用的区域不会生成很多事件。
如果您希望它是区域性的,那么类似这样的方法应该可以工作。只需在运行模板之前定义参数,我将它们放在 json 文件中。
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
ApplyToUsEast1:
Description: Whether to create resource in US-East-1. Value "true" or "false".
Type: String
ApplyToUsWest1:
Description: Whether to create resource in US-West-1. Value "true" or "false".
Type: String
Conditions:
ConditionUSEast1: !Equals [ !Ref ApplyToUsEast1, "true"]
ConditionUSWest1: !Equals [ !Ref ApplyToUsWest1, "true"]
Resources:
AggregatorUSEast1:
Condition: ConditionUSEast1
Type: AWS::Config::AggregationAuthorization
AggregatorUSWest1:
Condition: ConditionUSWest1
Type: AWS::Config::AggregationAuthorization
参数文件
[
{
"ParameterKey": "ApplyToUsEast1",
"ParameterValue": "true"
},
{
"ParameterKey": "ApplyToUsWest1",
"ParameterValue": "false"
}
]
像这样运行
aws cloudformation create-stack --stack-name config --template-body file://config.yaml --parameters file://config.json