Amazon web services 环境变量中的CloudFormation键值对
我是AWS的新手,所以我在这里提出的问题可能听起来很基本。我正在尝试定义cloudformation模板,我需要标记我创建的每个资源 我可以使用以下方法轻松创建资源和应用标记Amazon web services 环境变量中的CloudFormation键值对,amazon-web-services,amazon-cloudformation,aws-cloudformation-custom-resource,Amazon Web Services,Amazon Cloudformation,Aws Cloudformation Custom Resource,我是AWS的新手,所以我在这里提出的问题可能听起来很基本。我正在尝试定义cloudformation模板,我需要标记我创建的每个资源 我可以使用以下方法轻松创建资源和应用标记 Resources: ResourceName1: Type: AWS::SSM::Parameter Properties: Name: 'ResourceName1' Type: String Value: 'Value' Tags:
Resources:
ResourceName1:
Type: AWS::SSM::Parameter
Properties:
Name: 'ResourceName1'
Type: String
Value: 'Value'
Tags:
a: 'some value A'
b: 'some value B'
c: 'some value C'
ResourceName2:
Type: AWS::SSM::Parameter
Properties:
Name: 'ResourceName2'
Type: String
Value: 'Value'
Tags:
a: 'some value A'
b: 'some value B'
c: 'some value C'
在这里,如果我创建多个资源,标记将被重复,如果我需要更改标记值,我必须为每个资源更改那么多时间,所以我在想,在我可以外部化标记的地方,是否可以执行下面的操作
Mappings:
EnvVariables:
tags:
[ a: 'some value A'
b: 'some value B'
c: 'some value C'
]
Resources:
ResourceName1:
Type: AWS::SSM::Parameter
Properties:
Name: 'ResourceName1'
Type: String
Value: 'Value'
Tags:
!FindInMap [EnvVariables, tags]
ResourceName2:
Type: AWS::SSM::Parameter
Properties:
Name: 'ResourceName2'
Type: String
Value: 'Value'
Tags:
!FindInMap [EnvVariables, tags]
这或者如果有任何其他方法在一个地方外部化标记并从资源中引用它,那么对标记进行更改将更容易。当您创建CloudFormation堆栈时,您可以将标记与支持标记的每个资源相关联,在堆栈中,通过在堆栈选项页上定义标记或使用CLI/API中的--tags标志。a)b) (a) (b) 我希望这有助于