Terraform

How to create multiple AWS instances but each with a different name?

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

resource "aws_instance" "server" {
  count = 6

  tags = {
    Name = "instance-${count.index}"
  }
}

The above configuration will create 6 instances, each with a different name.