[英]Use Tags of Stack in CloudFormation
I am quite new at designing CloudFormation Template, is it possible to use stack tags value defined just before launching the stack creation inside the template? 我在设计CloudFormation模板时还很陌生,是否可以在模板内部启动堆栈创建之前使用定义的堆栈标签值?
For example : 例如 :
"EC2I2C2EJ": {
"Type": "AWS::EC2::Instance",
"Properties": {
"AvailabilityZone": "eu-west-3a",
"ImageId": "ami-0152e5e7567b014fc",
"InstanceType": { "Ref" : "Type" }
}
}
Yes you can apply tags to the Cloudformation stack without having to manually fill them in through the Create Stack Wizard however this needs to be done over the CLI or using Boto3/CreateStack API call. 是的,您可以将标签应用于Cloudformation堆栈,而无需通过“创建堆栈向导”手动填写它们,但这需要通过CLI或使用Boto3 / CreateStack API调用来完成。 Tags will automatically be added to your Cloudformation stack via this method and these tags will also - where appropriate - propagate onto resources you launch, ie the EC2 instance you are creating. 标签将通过此方法自动添加到您的Cloudformation堆栈中,并且这些标签还将(在适当情况下)传播到您启动的资源(即正在创建的EC2实例)上。
You can add tags inside the Cloudformation template like so for specific resources: 您可以像这样针对特定资源在Cloudformation模板内添加标签:
"EC2I2C2EJ": {
"Type": "AWS::EC2::Instance",
"Properties": {
"AvailabilityZone": "eu-west-3a",
"ImageId": "ami-0152e5e7567b014fc",
"InstanceType": { "Ref" : "Type" },
"Tags" : [
{
"Key" : "Tag1",
"Value" : "Test"
},
]
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.