答案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