count
で台数指定"ec2-%02d", count.index + 1
でタグ名をインクリメント
1 2 3 4 5 6 7 8 9 10 11 |
resource "aws_instance" "ec2" { count = 3 ami = "ami-0f310fced6141e627" instance_type = "t3.micro" subnet_id = aws_subnet.private_subnet-1a.id vpc_security_group_ids = [aws_security_group.ec2_security_group .id] tags = { Name = "${format("ec2-%02d", count.index + 1)}" } } |