title: Terraform tuple to map conversion
body: <p>I am pretty new to Terraform and I am using this function to re-use same list of subnets to launch more instances than subnets I have.  (It'll just loop over) This works great if I provide my own map of subnets but the data in the remote state is a tuple and I get this error:</p>
  
  <p><code>Invalid value for "inputMap" parameter: lookup() requires a map as the first
  argument.  data.terraform_remote_state.vpc.outputs.private_subnets is tuple with 4 elements</code></p>
  
  <p>I have also tried the <strong>tomap(</strong> function but this fails with:</p>
  
  <p><code>Invalid value for "v" parameter: cannot convert tuple to map of any single
  type.</code></p>
  
  <p>Here is my code:</p>
  
  <pre><code>  count                  = var.instance_count
    ami                    = var.ami
    instance_type          = "t2.medium"
    subnet_id              = lookup(data.terraform_remote_state.vpc.outputs.private_subnets, count.index%length(data.terraform_remote_state.vpc.outputs.private_subnets))
    vpc_security_group_ids = ["${data.terraform_remote_state.foo_sg.outputs.foo_sg_id}"]
    key_name               = var.key_name
    iam_instance_profile   = var.iam_instance_profile
  
    user_data = &lt;&lt;-EOF
                #!/bin/bash
                hostnamectl set-hostname --static "${var.app_name}-${count.index + 1}.${data.terraform_remote_state.vpc.outputs.private_zone_domain_name}"
                echo "127.0.0.1 localhost.localdomain localhost4 localhost4.localdomain4 ${var.app_name}-${count.index + 1}.${data.terraform_remote_state.vpc.outputs.private_zone_domain_name} localhost" &gt; hosts
                echo "::1 localhost localhost.localdomain localhost6 localhost6.localdomain6" &gt;&gt; hosts
                EOF
  
    tags = {
      Name                 = "${var.app_name}-${count.index +1}.${data.terraform_remote_state.vpc.outputs.private_zone_domain_name}"
  }
  
  </code></pre>
  
  <p>Like I said my goal is to re-use the 4 subnets in that remote state I have, so if I want 6 instances it would loop through the 4 I have and the 5th and 6th instance would be on subnet 1 and 2 in the Tuple. Any suggestions would be appreciated!</p>