title: Terraform Interpolation Into a var with map lookup
body: <p>I have exported my current resources using <a href="https://github.com/dtan4/terraforming" rel="nofollow noreferrer">Terraforming</a> and got a huge file which holds all the security groups.</p>
  
  <p>The thing is, that in each security group there are some rules which refers to the security groups IDs - which doesnt exists in the new region i'm planning to run terraform on. for example:</p>
  
  <pre><code>resource "aws_security_group" "my-group" {
      name        = "my-group"
      description = ""
      vpc_id      = "${var.vpc["production"]}"
  
      ingress {
          from_port       = 80
          to_port         = 80
          protocol        = "tcp"
          security_groups = ["sg-25bee542"] &lt;-- this ID doesnt exists in the new region i'm planning to work on
          self            = false
      }
  </code></pre>
  
  <p>I've created a map with all the old security groups:</p>
  
  <pre><code>variable "security_groups" {
      type    = "map"
      default = {
          "sg-acd22fdb" = "default"
          "sg-52cd3025" = "my-group"
          "sg-25bee542" = "my-group2"
          ...
      }
  }
  </code></pre>
  
  <p>Now I am trying to resolve the hard coded <code>sg-*id*</code> to the corresponding security group name and interpolate that into a variable so the first example will work this way:</p>
  
  <pre><code>resource "aws_security_group" "my-group" {
      name        = "my-group"
      description = ""
      vpc_id      = "${var.vpc["production"]}"
  
      ingress {
          from_port       = 80
          to_port         = 80
          protocol        = "tcp"
          security_groups = ["${aws_security_group.my-group2.id}"] &lt;-- the 'my-group2' should be resolved from the map variable
          self            = false
      }
  </code></pre>
  
  <p>Something like:</p>
  
  <pre><code>resource "aws_security_group" "my-group" {
      name        = "my-group"
      description = ""
      vpc_id      = "${var.vpc["production"]}"
  
      ingress {
          from_port       = 80
          to_port         = 80
          protocol        = "tcp"
          security_groups = ["${aws_security_group.[lookup(security_groups,sg-25bee542]].id}"] &lt;-- the 'my-group2' string should be resolved from the map variable by looking its sg ID
          self            = false
      }
  </code></pre>
  
  <p>I hope I made myself clear on that issue...any ideas?</p>