Example usage for com.amazonaws.services.ec2 AmazonEC2Client describeSubnets

List of usage examples for com.amazonaws.services.ec2 AmazonEC2Client describeSubnets

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2 AmazonEC2Client describeSubnets.

Prototype

@Override
    public DescribeSubnetsResult describeSubnets() 

Source Link

Usage

From source file:io.macgyver.plugin.cloud.aws.scanner.SubnetScanner.java

License:Apache License

@Override
public void scan(Region region) {
    AmazonEC2Client c = getAWSServiceClient().createEC2Client(region);

    DescribeSubnetsResult result = c.describeSubnets();

    GraphNodeGarbageCollector gc = newGarbageCollector().label("AwsSubnet").region(region);

    result.getSubnets().forEach(it -> {
        try {/*from   w ww . j  a  v a2  s . c o  m*/
            ObjectNode n = convertAwsObject(it, region);

            String cypher = "MERGE (v:AwsSubnet {aws_arn:{aws_arn}}) set v+={props}, v.updateTs=timestamp() return v";

            NeoRxClient client = getNeoRxClient();
            Preconditions.checkNotNull(client);
            client.execCypher(cypher, "aws_arn", n.get("aws_arn").asText(), "props", n)
                    .forEach(gc.MERGE_ACTION);

        } catch (RuntimeException e) {
            logger.warn("problem scanning subnets", e);
        }
    });

    gc.invoke();
}

From source file:org.wildfly.camel.test.common.aws.EC2Utils.java

License:Apache License

public static String getSubnetId(AmazonEC2Client ec2Client) {
    Subnet subnet = null;//from  w  w w . ja  v  a2 s .co  m
    for (Subnet aux : ec2Client.describeSubnets().getSubnets()) {
        System.out.println();
        if (aux.getState().equals("available") && aux.getAvailabilityZone().startsWith("eu-west-1")) {
            subnet = aux;
            break;
        }
    }
    Assert.assertNotNull("Subnet not null", subnet);
    return subnet.getSubnetId();
}