'Tagging multiple EC2 instances with terraform
how can I set different tags for whatever number of instances I'll create? the problem here is the servers will be server-1, server-2, etc.., but what I actually want is to set different values instead of using the value "Server" for all instances.
resource "aws_instance" "myapp-server" {
ami = data.aws_ami.Latest-amazon-linux-image.id
instance_type = var.instance_type
count = "${var.instance_count}"
subnet_id = aws_subnet.public-subnet-1.id
vpc_security_group_ids = [aws_default_security_group.default-sg.id]
availability_zone = var.az
associate_public_ip_address = true
tags = {
Name = "Server-${count.index+1}"
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
