Search in sources :

Example 1 with DescribeVpcsResponse

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);
    }
}
Also used : DescribeVpcsRequest(software.amazon.awssdk.services.ec2.model.DescribeVpcsRequest) Ec2Exception(software.amazon.awssdk.services.ec2.model.Ec2Exception) Vpc(software.amazon.awssdk.services.ec2.model.Vpc) DescribeVpcsResponse(software.amazon.awssdk.services.ec2.model.DescribeVpcsResponse)

Aggregations

DescribeVpcsRequest (software.amazon.awssdk.services.ec2.model.DescribeVpcsRequest)1 DescribeVpcsResponse (software.amazon.awssdk.services.ec2.model.DescribeVpcsResponse)1 Ec2Exception (software.amazon.awssdk.services.ec2.model.Ec2Exception)1 Vpc (software.amazon.awssdk.services.ec2.model.Vpc)1