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.
A.G. 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).
Names must begin with a letter; contain only ASCII letters, digits, and hyphens; and not end with a hyphen or contain two consecutive hyphens. Also, don't manage stack resources outside of CloudFormation.
In order to make a change to an immutable property, AWS CloudFormation must launch a replacement resource, in this case a new Amazon EC2 instance running the new AMI. After the new instance is running, AWS CloudFormation updates the other resources in the stack to point to the new resource.
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" }} ] } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With