Count :
resource "aws_instance" "www" {
ami = "ami-8ee056f3"
instance_type = "t2.micro"
key_name = "aws-ssh-key"
count = 2
tags = {
Name = "www${count.index}"
}
}
For_Each :
locals {
volumes = toset([
"data",
"backup",
])
}
resource "aws_ebs_volume" "vol" {
for_each = local.volumes
availability_zone = "us-west-2a"
size = 10
tags = {
Name = "Volume ${each.key}"
}
}
