I have 3 private subnets and in each subnet i want to spin 3 different EC2 instance using 3 different AWS Auto scaling group. Maximum there will be only 1 ec2 as part of each auto scaling group. There will be 3 different auto scaling group for each subnet. we don’t use public elastic ip and we need only private ip.
I am using terraform launch template to launch ec2 using a already available ENI or network interface id. but when running apply command, i am getting following error
Error: updating Auto Scaling Group (asg-corp-int-nifi-cluster-node-1): operation error Auto Scaling: UpdateAutoScalingGroup, https response error StatusCode: 400, RequestID: 00d34b0e-22-4fca-a0f4-23232, api error ValidationError: You must use a valid fully-formed launch template. A network interface may not specify both a network interface ID and a subnet
I have following 2 network_interface section in aws_launch_template
network_interfaces {
device_index = 0
associate_public_ip_address = false
}
network_interfaces {
device_index = 1
network_interface_id = aws_network_interface.secondary.id
}
Previously i have created the ENI with a static private IP
resource "aws_network_interface" "secondary" {
subnet_id = "subnet-343434343"
private_ips = ["10.14.10.22"]
}