在模板中为堆栈提供标签

在模板中为堆栈提供标签

本文介绍了AWS云形成模板-在模板中为堆栈提供标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想将公司特定的标签用于我们在AWS中创建的用于计费的资源。我正在使用云形成模板来启动我们的Elasticbeanstalk实例和其他依赖项目的资源。当我使用CloudFormation控制台创建堆栈时,它会要求我在参数后面的页面中提供标签。我必须手动输入该堆栈的标签。但是,是否可以在云形成模板本身中指定这些标签(用于堆栈的标签)?这样标签就可以传播到其他资源了吗?我知道云的形成会自动使用堆栈名称标记资源。但是我们需要公司特定的标签来向各个部门收费。

We wanted to use company specific Tags to the resources that we create in AWS for billing purposes. I am using a cloud formation template to spin up our Elasticbeanstalk instance and other project dependent resources. When I use the CloudFormation console to create a stack it asks me for Tags in the page after parameters. I have to manually input the Tags for that stack. However is there a way to specify those Tags (Tags for the stack) with in the cloud formation template itself? That way the Tag gets propagated to the other resources? I know that the cloud formation automatically tags the resources with the stack name. But we need company specific tags to bill separate departments.

推荐答案

启动AWS CloudFormation时,所请求的标签将应用于CloudFormation堆栈本身以及(如果可能)还将传播到堆栈所启动的资源中。

When launching AWS CloudFormation, the tags being requested will be applied to the CloudFormation Stack itself and (where possible) will also be propagated to the resources launched by the Stack.

这些标记可以传递给CreateStack API调用,也可以传递给CLI :

These tags can be passed to the CreateStack API call, or from the CLI:


  • 请参阅:

  • See: create-stack CLI documentation

这些标签将应用于

但是,CloudFormation模板可以包含针对正在创建的特定资源的标签。例如,启动Amazon EC2实例时,标签可以包含在模板中:

However, CloudFormation templates can include tags for specific resources that are being created. For example, when launching Amazon EC2 instances, tags can be included in the template:

"MyInstance" : {
    "Type" : "AWS::EC2::Instance",
    "Properties" : {
        "SecurityGroups" : [ { "Ref" : "MySecurityGroup" } ],
        "AvailabilityZone" : "us-east-1a",
        "ImageId" : "ami-20b65349",
        "Volumes" : [
            { "VolumeId" : { "Ref" : "MyEBS" },
                       "Device" : "/dev/sdk" }
        ],
        "Tags" : [
            {
                "Key" : "Stage",
                "Value" : "QA"
            }
       ]
    }
}

这篇关于AWS云形成模板-在模板中为堆栈提供标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 05:40