云形式名称EC2实例带有标签

发布于 2025-02-05 17:00:16 字数 157 浏览 1 评论 0原文

我正在尝试将我的云形式模板创建的EC2实例一个名称。

  Tags:
    - Key: Name
    - Value: "blah"

导致错误“在标签属性中找不到的密钥”。我看到示例中引用的密钥“名称”。我为什么不能使用它?谢谢

I'm trying to give the EC2 instance created by my Cloudformation template a name.

  Tags:
    - Key: Name
    - Value: "blah"

Results in the error "Key not found in Tags property". I see the key "Name" referenced in examples. Why can't I use it? Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浮光之海 2025-02-12 17:00:16

YAML将每个连字符视为指示列表中的新元素,因此您的定义转化为JSON,看起来像这样:

{
  "Tags": [
    {"Key": "Name" },
    {"Value": "blah" },
  ]
}

要修复,请在value

  Tags:
    - Key: Name
      Value: "blah"

YAML treats each hyphen as indicating a new element in a list, so your definition translates to JSON looking like this:

{
  "Tags": [
    {"Key": "Name" },
    {"Value": "blah" },
  ]
}

To fix, remove the hyphen before Value:

  Tags:
    - Key: Name
      Value: "blah"
探春 2025-02-12 17:00:16

问题可能是您没有将名称声明为变量,所以这应该有效:

Tags:
  - Key: "Name"
    Value: "blah"

The problem is probably that you did not declare the Name as a variable, so this should work:

Tags:
  - Key: "Name"
    Value: "blah"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文