title: Terrafrom datasource aws_vpcs - count.index error
body: <p>I am trying to use data source aws_vpcs to get the vpc id having specific tag.</p>
  
  <p>For reference:
  <a href="https://www.terraform.io/docs/providers/aws/d/vpcs.html" rel="nofollow noreferrer">https://www.terraform.io/docs/providers/aws/d/vpcs.html</a></p>
  
  <p>Below is my terraform yaml file.
  Terrafrom version used is: 0.12.3</p>
  
  <pre><code>data "aws_vpcs" "foo" {
    tags = {
      Name = "test1-VPC"
    }
  }
  
  resource "aws_security_group" "cluster" {
    count = "${length(data.aws_vpcs.foo.ids)}"
    vpc_id = "${tolist(data.aws_vpcs.foo.ids)[count.index]}"
  }
  
  resource "aws_security_group_rule" "cluster-ingress-node-https" {
    description              = "Rule to do xyz"
    from_port                = 443
    protocol                 = "tcp"
    security_group_id        = "${aws_security_group.cluster.id}"
    to_port                  = 443
    type                     = "ingress"
  }
  </code></pre>
  
  <p>I am getting below error. Request for help to fix this</p>
  
  <pre><code>terraform plan
  
  Error: Missing resource instance key
  
    on modules/eks/eks-cluster.tf line 40, in resource "aws_security_group_rule" "cluster-ingress-node-https":
    40:   security_group_id        = "${aws_security_group.cluster.id}"
  
  Because aws_security_group.cluster has "count" set, its attributes must be
  accessed on specific instances.
  
  For example, to correlate with indices of a referring resource, use:
      aws_security_group.cluster[count.index]
  </code></pre>