Iha*_*hok 5 templates yaml amazon-web-services aws-cloudformation
我可以将标签定义为参数部分 AWS CloudFormation 模板中的参数并在每个创建的资源中使用它吗?
我当前的模板:
AWSTemplateFormatVersion: 2010-09-09
Description: "Some information"
Parameters:
Test1:
Type: String
Description: Test1
Default: t1
Test2:
Type: String
Description: Test2
Default: t2
...
LBSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupDescription: "Enable access to app loadbalancer"
Tags:
- Key: Name
Value: !Join
- ""
- - !Ref Test1
- !Ref Test2
- Key: Test1
Value: !Ref Test1
- Key: Test2
Value: !Ref Test2
Run Code Online (Sandbox Code Playgroud)
我对任何其他资源(AWS::ElasticLoadBalancing::LoadBalancer、AWS::AutoScaling::AutoScalingGroup 等)使用相同的标签,这似乎是重复的代码(每次我创建新资源时)。我可以制作这样的东西吗?:
AWSTemplateFormatVersion: 2010-09-09
Description: "Some information"
Parameters:
Test1:
Type: String
Description: Test1
Default: t1
Test2:
Type: String
Description: Test2
Default: t2
Tag:
#define all tags, which I created above
...
LBSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupDescription: "Enable access to app loadbalancer"
Tags: !Ref Tag
...
Run Code Online (Sandbox Code Playgroud)
不幸的是,我没有在https://docs.aws.amazon.com/上找到任何关于它的信息
小智 5
您可以将标签应用到堆栈,它们将传播到资源。
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html
所有堆栈级标签(包括自动创建的标签)都会传播到 AWS CloudFormation 支持的资源。目前,标签不会传播到从块储存设备映射创建的 Amazon EBS 卷。
例如:
aws cloudformation create-stack --stack-name my-stack
--template-url <template>
--parameters ParameterKey=Param1,ParameterValue=Value1
--tags Key=Tag1,Value=Value1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4501 次 |
| 最近记录: |