Hi
I have created this terraform template referencing a variable file. Basically I want to create 2 Instances which will have two interfaces, and each of these interfaces will reside in two seperate subnet. My brain is hurting to try figure it out. What is happening subnet ID is that it is applying subnet 1 to instance1 and subnet 2 to instance2. I want the instance to launch in subnet 1 and subnet 2. eth0 pointing to subnet xxxx and eth1 pointing to subnet bbbb. Hope this makes sense. Thanks
Here is my code
variable “ami”
{default = “ami-xxxx”
}
variable “instance_count” {
default = “2”
}
variable “instance_tags” {
type = “list”
default = [“testpc1”, “testpc22”]
}
variable “subnet_id” {
type = “string”
default = “subnet-xxxxxxx”
}
variable “subnet_ids” {
description = “A list of VPC Subnet IDs to launch in”
type = “list”
default = [“subnet-xxxx” ,“subnet-bbbb”]
}
variable “instance_type” {
default = “t2.micro”
}
resource “aws_instance” “my-instance” {
count = “{var.instance\_count}"
ami = "{var.ami}”
subnet_id = “{element(var.subnet\_ids, count.index)}"
instance\_type = "{var.instance_type}”
tags = {
Name = “${element(var.instance_tags, count.index)}”
}
}