title: Make VPC creation optional
body: <p>I am trying to make VPC creation conditional in my cloudformation script. For example, if there is a VPC id provided in the parameters, then I want to create all resources in this VPC, otherwise to create a new one. </p>
  
  <p>The problem starts when I want to reuse an existing VPC, but I have no way of deducing the subnets, which I need for one of my resources. So I suppose, I have to provide them as parameters. But if I provide them as parameters, in the case where I want to create a new VPC, it complains because the list of subnet ids is empty and it must be a valid one. </p>
  
  <p>The error is <code>Parameter validation failed: parameter value for parameter name VpcPrivateSubnetIds does not exist. Rollback requested by user.</code> It is impossible to give any dummy value. Any ideas how to achieve this?</p>
  
  <p>Here is my CF script:</p>
  
  <pre><code>VpcId:
    Type: String
    Description: Give the VPC id if you want to use an existing one. Leave empty for creating a new one.
  
  VpcPublicSubnetIds:
    Type: List&lt;AWS::EC2::Subnet::Id&gt;
    Description: List of 3 public SubnetIds for the given VPC. 
  
  VpcPrivateSubnetIds:
    Type: List&lt;AWS::EC2::Subnet::Id&gt;
    Description: List of 3 private SubnetIds for the given VPC. 
  
  
  Conditions:
    CreateVPC: !Equals [ !Ref VpcId, ""]
  
  
  Resources: 
    (...)
      Properties:
        PrivateSubnetIds: !If
          - CreateVPC
          - !GetAtt VPCStack.Outputs.PrivateSubnets
          - !Join [',', [!Select [0, !Ref VpcPrivateSubnetIds], !Select [1, !Ref VpcPrivateSubnetIds], !Select [2, !Ref VpcPrivateSubnetIds]]]
        PublicSubnetIds: !If
          - CreateVPC
          - !GetAtt VPCStack.Outputs.PublicSubnets
          - !Join [',', [!Select [0, !Ref VpcPublicSubnetIds], !Select [1, !Ref VpcPublicSubnetIds], !Select [2, !Ref VpcPublicSubnetIds]]]
  </code></pre>