Name an EC2 Instance in the CloudFormation template?

Amazon Web-ServicesAmazon Ec2Amazon Cloudformation

Amazon Web-Services Problem Overview


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.

Amazon Web-Services Solutions


Solution 1 - Amazon Web-Services

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" }}
        ]
    }
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionA.G.View Question on Stackoverflow
Solution 1 - Amazon Web-ServicesPete - MSFTView Answer on Stackoverflow