Cycle error in Terraform when combining ELB and Auto Scaling Group
<p>I want to create an ASG with only 1 instance initially. </p>

<p>I want all the instances of this ASG to be behind an ELB. </p>

<p>So I set <code>load_balancers = ["${aws_elb.Production-Web-ELB.name}"]</code> in the <code>resource "aws_autoscaling_group" "ProductionWeb-ScalingGroup"</code> .</p>

<p>Now, when I write the code for the <code>resource "aws_elb" "Production-Web-ELB"</code>, and I set <code>instances = ["${aws_autoscaling_group.ProductionWeb-ScalingGroup.*.id}"]</code>, I get the error...</p>

<pre><code>Error configuring: 1 error(s) occurred:

* Cycle: aws_autoscaling_group.ProductionWeb-ScalingGroup, aws_elb.Production-Web-ELB
</code></pre>

<p>I understand that this error means that the one resource references the other in a circle. To check it I comment out the <code>load_balancers = ["${aws_elb.Production-Web-ELB.name}"]</code> part and <code>terraform plan</code> without any error.</p>

<p>So my question is: Am I unable using Terraform to create an ASG with an attached ELB and every EC2 that will spawn inside it will be automatically behind the ELB ? </p>

<p>Is there something from the documentation that I missed? </p>

<p>Is there a workaround?</p>