0
votes

I have successfully provision the AWS infrastructure using terraform.

While attaching more than one instance (multiple instances) to AWS ELB, I am able to attach the instances using Autoscaling.

resource "aws_elb" "abc-ext-elb" { name = "${var.galaxy}-abc-ext-elb" listener { } listener { } listener { } } security_groups = ["${aws_security_group.xxxx}"] subnets = ["${xxxxx}"] instances = ["${aws_instance.myinstance.id}"]

And also I have tried like:

"instances = "${element(aws_instance.mqttcluster.id, count.index)}" 

In both the cases it did not work

But while adding the instances without auto scaling, only one instance I am able to add using terraform, I am not able to add more than one instance from same group of instances. How to solve this issue? I did not find any module for this.

2
Please show your codeAnshu Prateek

2 Answers

1
votes

How did you define your elb? it should be something like this:

resource "aws_elb" "my-elb" {
    ...
    instances = ["${aws_instance.myinstances.*.id}"]
    ...
}
1
votes

just remove [] from instances and it should

instances = ["${aws_instance.myinstances.*.id}"]