title: Using Count in Terraform to create Launch Configuration
body: <p>I have 3 different version of an AMI, for 3 different nodes in a cluster.</p>
  
  <pre><code>data "aws_ami" "node1"
  {
    # Use the most recent AMI that matches the pattern below in 'values'.
    most_recent = true
  
    filter {
      name = "name"
      values = ["AMI_node1*"]
    }
  
    filter {
      name = "tag:version"
      values = ["${var.node1_version}"]
    }
  
  }
  
  data "aws_ami" "node2"
  {
    # Use the most recent AMI that matches the pattern below in 'values'.
    most_recent = true
  
    filter {
      name = "name"
      values = ["AMI_node2*"]
    }
  
    filter {
      name = "tag:version"
      values = ["${var.node2_version}"]
    }
  
  }
  
  data "aws_ami" "node3"
  {
    ...
  }
  </code></pre>
  
  <p>I would like to create 3 different Launch Configuration and Auto Scaling Group using each of the AMIs respectively. </p>
  
  <pre><code>resource "aws_launch_configuration" "node"
  {
    count = "${local.node_instance_count}"
    # Name-prefix must be used otherwise terraform fails to perform updates to existing launch configurations due to
    # a name conflict: LCs are immutable and the LC cannot be destroyed without destroying attached ASGs as well, which
    # terraform will not do. Using name-prefix lets a new LC be created and swapped into the ASG.
    name_prefix = "${var.environment_name}-node${count.index + 1}-"
    image_id = "${data.aws_ami.node[count.index].image_id}"
    instance_type = "${var.default_ec2_instance_type}"
   ...
  }
  </code></pre>
  
  <p>However, I am not able use <code>aws_ami.node1</code>, <code>aws_ami.node2</code>, <code>aws_ami.node3</code> using the cound.index the way I have shown above. I get the following error:</p>
  
  <pre><code>Error reading config for aws_launch_configuration[node]: parse error at 1:39: expected "}" but found "."
  </code></pre>
  
  <p>Is there another way I can do this in Terraform?</p>