title: Terraform how to get dynamic route in route table
body: <p><strong>Terraform how to get dynamic route in route table based on the workspace</strong></p>
  <blockquote>
  <p>UAT</p>
  </blockquote>
  <pre><code>resource &quot;aws_vpn_gateway&quot; &quot;micorsoft_vpn_gw&quot; { 
    vpc_id = aws_vpc.default.id
  
    tags = {
      Name = &quot;micorsoft&quot;
    }
  }
  
  resource &quot;aws_route_table&quot; &quot;private&quot; { 
    vpc_id = aws_vpc.default.id
    route {
      cidr_block     = &quot;0.0.0.0/0&quot;
      nat_gateway_id = aws_nat_gateway.default.id
    }
    
    route {
      cidr_block     = &quot;0.0.0.0/0&quot;
      gateway_id     =  aws_vpn_gateway.micorsoft_vpn_gw.id
    }
  
    tags = merge(map(&quot;Name&quot;, &quot;${var.namespace}-${var.environment}&quot;), var.tags)
  }
  </code></pre>
  <blockquote>
  <p>DEV</p>
  </blockquote>
  <pre><code>resource &quot;aws_route_table&quot; &quot;private&quot; { 
    vpc_id = aws_vpc.default.id
    route {
      cidr_block     = &quot;0.0.0.0/0&quot;
      nat_gateway_id = aws_nat_gateway.default.id
    }
   
    tags = merge(map(&quot;Name&quot;, &quot;${var.namespace}-${var.environment}&quot;), var.tags)
  }
  </code></pre>
  <p>How to achieve this is dynamic way based on workdspace/environment</p>