title: Terraform - AWS - create multiple instances - different AZ (where instance count is greater than AZ list length)
body: <p>I am facing a problem with Terraform (v0.12) to create multiple instances using count variable and subnet id's list, where the count is greater than the length of the subnet id's list.</p>
  
  <p>For example;</p>
  
  <pre><code>resource "aws_instance" "main" {
    count                     = 20
    ami                       = var.ami_id
    instance_type             = var.instance_type
    # ...
    subnet_id                 = var.subnet_ids_list[count.index]
  }
  </code></pre>
  
  <p>Where my count is '20' and <code>length(var.subnet_ids_list)</code> is 2. It throws the following error:</p>
  
  <pre><code>count.index is 2
      var.instance_subnet_id is tuple with 2 elements
  
  The given key does not identify an element in this collection value.
  </code></pre>
  
  <p>I tried to make the "subnet_ids_list" as string with comma-separated and used "split", but it too give the same error.</p>
  
  <p>Later thought to append subnet elements to "subnet_ids_list" in order to make it to "20". something like;</p>
  
  <pre><code>Python 2.7
  &gt;&gt;&gt; subnet_ids_list = subnet_ids_list * 10
  </code></pre>
  
  <p>Can someone help me with how to achieve similar with Terraform or any other approaches to solve this problem.</p>
  
  <p>Original like;</p>
  
  <pre><code>subnet_ids_list = ["sub-1", "sub-2"]
  </code></pre>
  
  <p>Converted to - satisfy the value provided to count;</p>
  
  <pre><code>subnet_ids_list = ["sub-1", "sub-2", "sub-1", "sub-2",....., "sub-1", "sub-2",] (length=20).
  </code></pre>
  
  <p>I don't want to use AWS autoscaling groups for this purpose.</p>