简体   繁体   English

CloudFormation加入标签

[英]CloudFormation Join in Tags

I'm running a CloudFormation template that uses the following snippet to tag various resources (this is a ELB tag, but others also exhibit this problem) I would expect this to produce a name tag of stackName-asgElb but it actually produces names such as olive-asg-asgElb-16GSCPHUFSWEN . 我正在运行一个CloudFormation模板,该模板使用以下代码片段标记各种资源(这是一个ELB标记,但其他人也会出现此问题)。我希望这会产生一个stackName-asgElb的名称标记,但实际上会产生诸如olive-asg-asgElb-16GSCPHUFSWEN

The stack name in this case was named olive-asg so I was expecting olive-asg-asgElb , without the -16GSCPHUFSWEN on the end. 在这种情况下,堆栈名称被命名为olive-asg因此我期待olive-asg-asgElb ,最后没有-16GSCPHUFSWEN

Does anybody know where the seemingly random string on the end comes from? 有人知道结尾处看似随机的字符串是从哪里来的吗?

CF template snippet : CF模板代码段

Tags: [
    {
        Key: "Name",
        Value: {
            "Fn::Join": [
                "-",
                [
                    {
                        Ref: "AWS::StackName"
                    },
                    "asgElb"
                ]
            ]
        }
    }
]

That's interesting, I just tried it and I'm not able to reproduce the same results that you're seeing. 很有意思,我只是尝试了一下,但无法重现您所看到的相同结果。 It seems to be working as expected. 它似乎按预期工作。

Here's the snippet I'm using in its entirety: 这是我完整使用的代码段:

"ElasticLoadBalancer" : {
  "Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
  "Properties" : {
    "AvailabilityZones" : { "Fn::GetAZs" : "" },
    "CrossZone" : "true",
    "Listeners" : [ {
      "LoadBalancerPort" : "80",
      "InstancePort" : "80",
      "Protocol" : "HTTP"
    } ],
    "Tags" : [
    {
        "Key" : "Name",
        "Value" : { "Fn::Join" : [ "-", [ { "Ref" : "AWS::StackName" }, "MyELB"] ] }
    }
    ]
  }
},

The one noticeable difference I see in yours is that you're missing some of the quotes around the Tag stanza. 我看到的一个明显区别是您缺少Tag节周围的一些引号。

I feel foolish, the name tags are set correctly, I was looking at the physical IDs, not the name tags. 我觉得很愚蠢,名称标签设置正确,我在查看物理ID,而不是名称标签。 The docs explaining how to control physical IDs are here . 解释如何控制物理ID的文档在此处

Thanks to @alanwill for testing, and forcing me to go back through all the steps carefully! 感谢@alanwill进行测试,并迫使我仔细完成所有步骤!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM