title: How do I specify subnet and VPC IDs in AWS CloudFormation?
body: <p>I want my CloudFormation template to use existing subnets and VPCs. I don't want to create new ones.</p>
  <p>How do I parameterize these?</p>
  <p>When I look at the docs for <code>AWS::EC2::VPC</code> and <code>AWS::EC2::Subnet</code>, it seems these resources are only for creating <em>new</em> VPCs and subnets. Is that correct?</p>
  <p>Should I just point the instance resource directly to the existing VPC and subnets I want it to use?</p>
  <p>For example - if I have an instance resource in my template and I point it directly to an existing subnet, like this:</p>
  <pre><code>{
    &quot;Resources&quot;: {
      &quot;MyServer&quot;: {
        &quot;Type&quot;: &quot;AWS::EC2::Instance&quot;,
        &quot;Properties&quot;: {
          &quot;InstanceType&quot;: {
            &quot;Ref&quot;: &quot;InstanceType&quot;
          },
  &quot;SubnetId&quot;: {
    &quot;Ref&quot;: &quot;subnet-abc123&quot;
  },
  ...
  </code></pre>
  <p>I get this error when validating the template:</p>
  <pre><code>Template contains errors.: Template format error: Unresolved resource dependencies [subnet-abc123] in the Resources block of the template
  </code></pre>
  <p>I tried to do this with mappings but still getting an error:</p>
  <pre><code>  &quot;Mappings&quot;: {
      &quot;SubnetID&quot;: {
        &quot;TopKey&quot;: {
          &quot;Default&quot;: &quot;subnet-abc123&quot;
        }
      }
  </code></pre>
  <p>And with this in the instance resource:</p>
  <pre><code>&quot;SubnetId&quot;: {
    &quot;Fn::FindInMap&quot;: [
      &quot;SubnetID&quot;,
      {
        &quot;Ref&quot;: &quot;TopKey&quot;
      },
      &quot;Default&quot;
    ]
  }
  </code></pre>
  <p>I get this error when trying to validate:</p>
  <pre><code>Template contains errors.: Template format error: Unresolved resource dependencies [TopKey] in the Resources block of the template
  </code></pre>