title: Launching Instance: VPC security groups may not be used for a non-VPC launch
body: <p>I'm attempting to create an instance in another region, but I get this error:</p>
  
  <pre><code>AWS Error Code: InvalidParameterCombination, AWS Error Message: VPC security groups may not be used for a non-VPC launch
  </code></pre>
  
  <p>Here is the code I'm executing.</p>
  
  <pre><code>RunInstancesRequest instancereq = new RunInstancesRequest();
  
  instancereq.setInstanceType("m3.medium");
  instancereq.setImageId("ami-37b1b45e");
  instancereq.setMinCount(1);
  instancereq.setMaxCount(1);
  
  ArrayList&lt;String&gt; secgroup = new ArrayList&lt;String&gt;();        
  instancereq.setKeyName("testkey");          
  secgroup.add("testdefault");          
  instancereq.setSecurityGroups(secgroup);
  
  instancereq.setPlacement(getAzPlacement());        
  RunInstancesResult instanceresult = ec2.runInstances(instancereq);
  </code></pre>
  
  <p>I've also tried, instead of using the name "testdefault", using the actual groupid <code>(sg-########)</code>, but I'll get an error saying that security group doesn't exist (which is wrong, it does).  Which, <a href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/ec2/model/RunInstancesRequest.html#setSecurityGroups%28java.util.Collection%29" rel="noreferrer">based on the API doc</a>, if using a non-default VPC, you should pass the actual groupid but I'll get an error like this:</p>
  
  <pre><code>InvalidGroup.NotFound, AWS Error Message: The security group 'sg-########' does not exist
  </code></pre>
  
  <p>If I use "default" as the <code>setSecurityGroups</code> it will use the default VPC. It just doesn't seem like like the groupid I'm passing, despite it being accurate.</p>
  
  <p>Also, if I comment out the <code>setSecurityGroups</code> code, and use <code>setSubnetId</code> instead and pass the subnet id, it will create the instance just fine, but it goes into the "default" security group, not "testdefault" like I want.</p>
  
  <p>All I'm trying to accomplish is creating an instance and having it use the already existing VPC group.</p>