Example usage for com.amazonaws.services.ec2 AmazonEC2 describeRegions

List of usage examples for com.amazonaws.services.ec2 AmazonEC2 describeRegions

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2 AmazonEC2 describeRegions.

Prototype

DescribeRegionsResult describeRegions();

Source Link

Document

Simplified method form for invoking the DescribeRegions operation.

Usage

From source file:aws.example.ec2.DescribeRegionsAndZones.java

License:Open Source License

public static void main(String[] args) {
    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    DescribeRegionsResult regions_response = ec2.describeRegions();

    for (Region region : regions_response.getRegions()) {
        System.out.printf("Found region %s " + "with endpoint %s", region.getRegionName(),
                region.getEndpoint());//from   w  w w.  ja  v a 2s  .c o  m
    }

    DescribeAvailabilityZonesResult zones_response = ec2.describeAvailabilityZones();

    for (AvailabilityZone zone : zones_response.getAvailabilityZones()) {
        System.out.printf("Found availability zone %s " + "with status %s " + "in region %s",
                zone.getZoneName(), zone.getState(), zone.getRegionName());
    }
}

From source file:com.appdynamics.connectors.AWSConnector.java

License:Apache License

private void validate(IProperty[] properties) throws InvalidObjectException {
    AmazonEC2 connector = ConnectorLocator.getInstance().getConnector(properties, controllerServices);

    // this will validate the access and secret keys
    try {/*www . j ava 2  s. c o m*/
        connector.describeRegions();
    } catch (AmazonServiceException e) {
        logger.log(Level.INFO, "", e);
        throw new InvalidObjectException("The specified " + Utils.ACCESS_KEY_PROP + " and/or "
                + Utils.SECRET_KEY_PROP + " is not valid.", e);
    } catch (AmazonClientException e) {

        logger.log(Level.INFO, "", e);
        throw new InvalidObjectException("The specified " + Utils.ACCESS_KEY_PROP + " and/or "
                + Utils.SECRET_KEY_PROP + " is not valid.", e);
    }
}

From source file:ec2.DescribeRegionsAndZones.java

License:Open Source License

public static void main(String[] args) {

    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    DescribeRegionsResult response = ec2.describeRegions();

    for (Region region : response.getRegions()) {
        System.out.printf("Found region %s with endpoint %s", region.getRegionName(), region.getEndpoint());
    }// w w w .  ja v  a2s. c o  m

    DescribeAvailabilityZonesResult describeAvailabilityZonesResponse = ec2.describeAvailabilityZones();

    for (AvailabilityZone zone : describeAvailabilityZonesResponse.getAvailabilityZones()) {
        System.out.printf("Found availability zone %s with status %s in region %s", zone.getRegionName(),
                zone.getState(), zone.getRegionName());
    }
}