Issue
I created an ec2 instance using Terraform code and added one tag. But I would like to add a default instance name as well to appear in the field shown in the below screenshot.
href="https://i.stack.imgur.com/ACBGO.png" rel="nofollow noreferrer">
How do I do that using Terraform?.
Right now, I tried the default
argument for the tag but did not seem to work. I find it hard to figure out from the doc.
Code that I currently used to create it:
resource "aws_instance" "webserver" {
ami = "ami-09a41e26df464c548"
instance_type = "t2.micro"
tags = {
default = "my-ec2-instance"
"Terraform" = "Yes"
}
}
Solution
You would want to add a tag with the key of Name
:
resource "aws_instance" "webserver" {
ami = "ami-09a41e26df464c548"
instance_type = "t2.micro"
tags = {
Name = "my-ec2-instance"
"Terraform" = "Yes"
}
}
The name of the instance will appear as such:
Answered By - Ervin Szilagyi Answer Checked By - David Goodson (WPSolving Volunteer)