Hi,
I want to create multiple ec2 instances and i’m usually doing it by creating block for each instance. how can I make, for example 3 instances in one block.
resource "aws_instance" "INSTANCES" {
ami = var.ami
instance_type = var.instance_type
key_name = var.key_name
subnet_id = var.subnet_id
vpc_security_group_ids = [var.vpc_security_group_ids]
iam_instance_profile = var.iam_instance_profile
tags = {
Name = "Instance_name"
}
user_data = file(var.user_data)
}
I tried to use the count and for_each, but I only manage to control limited stuff.
I would want in one block to give every node:
- different tag name
- different user_data_file
- different subnet_id
how can i do that?