title: Terraform AWS - Creation of multiple AWS S2S VPN
body: <p>Requirement is to establish communication from multiple offices to AWS through Terraform. Below is the code so far where the customer gateway and virtual private gateway will be created based on the variable map cgw (Lets assume 5 customer gateways)</p>
  <pre><code>resource &quot;aws_customer_gateway&quot; &quot;cgw-main&quot; {
    for_each   = toset(var.cgw)
    ip_address = each.value
    bgp_asn    = 65000
    type       = &quot;ipsec.1&quot;
  }
  
  
  resource &quot;aws_vpn_gateway&quot; &quot;vpn-gw-main&quot; {
    count  = length(var.cgw)
    vpc_id = aws_vpc.myvpc.id
  }
  
  resource &quot;aws_vpn_connection&quot; &quot;vpn-main&quot; {
    customer_gateway_id= ??
    vpn_gateway_id = ??
    type=&quot;ipsec.1&quot;
    static_routes_only = true
  }
  
  </code></pre>
  <p>How do i dynamically pickup each created customer gateway and map to created vpn gateway in  aws_vpn_connection for 5 iterations?</p>