use of software.amazon.awssdk.services.ec2.model.DescribeVpcsResponse in project aws-doc-sdk-examples by awsdocs.
the class DescribeVPCs method describeEC2Vpcs.
// snippet-start:[ec2.java2.describe_vpc.main]
public static void describeEC2Vpcs(Ec2Client ec2, String vpcId) {
try {
DescribeVpcsRequest request = DescribeVpcsRequest.builder().vpcIds(vpcId).build();
DescribeVpcsResponse response = ec2.describeVpcs(request);
for (Vpc vpc : response.vpcs()) {
System.out.printf("Found VPC with id %s, " + "vpc state %s " + "and tennancy %s", vpc.vpcId(), vpc.stateAsString(), vpc.instanceTenancyAsString());
}
} catch (Ec2Exception e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
Aggregations