title: How to get the VPC id from subnet ID using aws java SDK?
body: <p>There is an existing subnet say subnet-11223344. In my code I want to know the VPC it belongs to.</p>
  
  <p>I am referring java SDK <a href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/ec2/model/Subnet.html" rel="nofollow noreferrer">http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/ec2/model/Subnet.html</a> </p>
  
  <pre><code>// I am not sure if this actually refres to a subnet that I want
  Subnet subnet = new Subnet().withSubnetId("subnet-11223344");
  String vpcId = subnet.getVpcId();
  System.out.println("VPC id"+vpcId); 
  </code></pre>
  
  <p>This returns null.</p>