title: terraform modules ec2 and vpc AWS
body: <p>I have question about how use modules in terraform.
  See below my code.</p>
  <pre><code>module &quot;aws_vpc&quot;{
    source = &quot;../modules/vpc&quot;
    vpc_cidr_block = &quot;192.168.0.0/16&quot;
    name_cidr = &quot;ec2-eks&quot;
    name_subnet = &quot;ec2-eks-subnet&quot;
    subnet_cidr = [&quot;192.168.1.0/25&quot;]
  }
  module &quot;ec2-eks&quot; {
    source = &quot;../modules/ec2&quot;
    ami_id = &quot;ami-07c8bc5c1ce9598c3&quot;
    subnet_id = module.aws_vpc.aws_subnet[0]
    count_server = 1
  }
  output &quot;aws_vpc&quot; {
    value = module.aws_vpc.aws_subnet[0]
  }
  </code></pre>
  <p>I`m creating a vpc and want the next step to attach ec2 by my created subnet.But terraform attached by VPC of default.
  What do I need to do that attach ec2 to my vpc(subnet)?
  Thank you for you answers</p>