56
votes

I have a template that works and generates a stack but I cannot find a property to set or something else that allows me to give a Name to the EC2 Instance I have created. When it is generated the Name is blank.

1
My comment is not about templates, but this is the only question I find about naming EC2 instances, so I'm writing this here. You can name an instance by select the instance and choosing Actions => Edit Tags and add a tag for Name (case sensitive). Also, if you hover your mouse over the blank field in the Name column a little pencil icon appears that you can click on that to edit the tag more directly.Emery Lapinski

1 Answers

93
votes

You need to add a tag with key Name to the cloud formation template. Like this...

"ec2-instance" : {
    "Type" : "AWS::EC2::Instance",
    "Properties" : {
        "ImageId" : "ami-0102022,
        "SecurityGroupIds" : [{ "Ref" : "SecurityGroup" }],
        "SubnetId" : { "Ref" : "Subnet" },
        "InstanceType" : "m1.medium",
        "Tags" : [
            {"Key" : "Name", "Value" : "Instance name"},
            {"Key" : "Environment", "Value" : { "Ref" : "Environment" }},
            {"Key" : "Owner", "Value" : { "Ref" : "Owner" }}
        ]
    }
}