title: terraform use count index in module
body: <p>I want to use the count.index in the terraform module for my aws ec2 instance to name the instance in increment order</p>
  
  <pre><code>file: ec2/main.tf
   resource "aws_instance" "instance"{
      ami = "ami-xxx"
      tags {
       Name = "var.instance"
       }
      count = "var.count"
  
  }
  
  </code></pre>
  
  <pre><code>file: ec2instance.tf
  
  module "ec2"{
   source = "./ec2"
   count = 3
   instance_name = "firsttypeinstance-${count.index+1}"
  }
  
  module "ec20"{
   source = "./ec2"
   count = 2
   instance_name = "secondtype-${count.index+1}"
  
  }
  
  </code></pre>
  
  <p>I want the instance name to be populated as </p>
  
  <p>firsttypeinstance-1
  firsttypeinstance-2
  firsttypeinstance-3</p>
  
  <p>secondtype-1
  secondtype-2</p>
  
  <p>but i get the error that i cannot use count index in the module</p>