title: AWS Elastic Beanstalk launching into default VPC
body: <p>I am trying to launch a Tomcat Beanstalk Instance into my VPC. But for some reason, the Instance does not consider my Configuration Template. </p>
  
  <p>What I have done :</p>
  
  <ol>
  <li>Created a VPC in a separate script and manually launched the requested instance and connected to it via SSH</li>
  </ol>
  
  <p>Problem 1:  If I use cloud-formation for some reason the script (below) creates a new stack for the Beanstalk </p>
  
  <p>Problem 2:  Upon successful launch, the beanstalk is created into the default VPC or crashes if I delete the default VPC.</p>
  
  <p>How can I debug this? 
  Why is this happening, since I pass the correct parameters to the script?</p>
  
  <pre><code>  SampleApplication:
      Type: 'AWS::ElasticBeanstalk::Application'
      Properties:
        ApplicationName: !Ref ApplicationName
        Description: OCAP's AWS Elastic Beanstalk Sample Application
  
    SampleApplicationVersion:
      Type: 'AWS::ElasticBeanstalk::ApplicationVersion'
      Properties:
        Description: Version 1.0
        ApplicationName: !Ref SampleApplication
        SourceBundle:
          S3Bucket: !Ref AppS3Bucket
          S3Key: !Ref AppS3Key
  
    SampleIdentityEnvironment:
      Type: 'AWS::ElasticBeanstalk::Environment'
      Properties:
        ApplicationName: !Ref SampleApplication
        EnvironmentName : OCAPSampleIdentityManager
        VersionLabel: !Ref SampleApplicationVersion
        SolutionStackName: !FindInMap [ StackMap, !Ref StackType, stackName ]
      DependsOn:
        - ConfigurationTemplate
        - SampleApplicationVersion
  </code></pre>
  
  <p>ConfigurationTemplate:</p>
  
  <pre><code>Type: AWS::ElasticBeanstalk::ConfigurationTemplate
  Properties:
    ApplicationName: !Ref SampleApplication
    Description: 64bit Amazon Linux running Tomcat 7
    SolutionStackName: !FindInMap [ StackMap, !Ref StackType, stackName ]
    OptionSettings:
  
      - Namespace: aws:autoscaling:launchconfiguration
        OptionName: EC2KeyName
        Value: !Ref KeyName
  
      - Namespace: aws:ec2:vpc
        OptionName: VPCId
        Value : vpc-0123456789
  
      - Namespace: 'aws:ec2:vpc'
        OptionName: Subnets
        Value: subnet-0123456789, subnet-0123456789
  
      - Namespace: 'aws:ec2:vpc'
        OptionName: ELBSubnets
        Value: subnet-0123456789, subnet-0123456789
  
      - Namespace: 'aws:ec2:vpc'
        OptionName: AssociatePublicIpAddress
        Value: 'true'
  </code></pre>