I'm attempting to deploy multiple EC2 instances, each in different subnets using the same aws_instance
resource block.
When I set the count parameter to more than one server it establishes them all in the same subnet.
Is there a way to accomplish this via Terraform?
Below you'll find my Terraform block:
resource "aws_instance" "ec2-instance" {
ami = "${var.ec2_ami}"
instance_type = "${var.instance_type}"
key_name = "${var.key_name}"
vpc_security_group_ids = ["${var.security_group}"]
subnet_id = "${var.subnet_id}"
count = "${var.count}"
root_block_device {
volume_size = "${var.root_volume_size}"
volume_type = "${var.root_volume_type}"
}
tags {
Name = "${var.app_name}"
}
}