Home > Blockchain >  Cloudformation Name EC2 Instance with Tags
Cloudformation Name EC2 Instance with Tags

Time:06-09

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

CodePudding user response:

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"

CodePudding user response:

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

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