Example usage for com.amazonaws.services.ec2.model DescribeVpcEndpointsResult getVpcEndpoints

List of usage examples for com.amazonaws.services.ec2.model DescribeVpcEndpointsResult getVpcEndpoints

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model DescribeVpcEndpointsResult getVpcEndpoints.

Prototype


public java.util.List<VpcEndpoint> getVpcEndpoints() 

Source Link

Document

Information about the endpoints.

Usage

From source file:org.lendingclub.mercator.aws.VPCEndpointScanner.java

License:Apache License

@Override
protected void doScan() {
    GraphNodeGarbageCollector gc = newGarbageCollector().bindScannerContext();
    DescribeVpcEndpointsRequest request = new DescribeVpcEndpointsRequest();
    do {//from w  w w.  ja v a 2 s.  c  o  m
        DescribeVpcEndpointsResult result = getClient().describeVpcEndpoints(request);
        result.getVpcEndpoints().forEach(endpoint -> {
            ObjectNode n = convertAwsObject(endpoint, getRegion());

            NeoRxClient neo4j = getNeoRxClient();
            try {
                String cypher = "merge (x:AwsVpcEndpoint {aws_arn:{arn}}) set x+={props}, x.updateTs=timestamp() return x";
                String arn = n.path("aws_arn").asText();
                neo4j.execCypher(cypher, "arn", arn, "props", n).forEach(it -> {
                    gc.MERGE_ACTION.accept(it);
                });

                LinkageHelper routeTableLinkage = new LinkageHelper().withNeo4j(neo4j)
                        .withFromLabel(getNeo4jLabel()).withFromArn(arn).withTargetLabel("AwsRouteTable")
                        .withLinkLabel("AVAILABLE_IN").withTargetValues(endpoint.getRouteTableIds().stream()
                                .map(r -> createEc2Arn("route-table", r)).collect(Collectors.toList()));

                routeTableLinkage.execute();

                LinkageHelper vpcLinkage = new LinkageHelper().withNeo4j(neo4j).withFromLabel(getNeo4jLabel())
                        .withFromArn(arn).withTargetLabel("AwsVpc").withLinkLabel("OWNED_BY")
                        .withTargetValues(Collections.singletonList(createEc2Arn("vpc", endpoint.getVpcId())));
                vpcLinkage.execute();

                incrementEntityCount();
            } catch (RuntimeException e) {
                gc.markException(e);
                maybeThrow(e);
            }
        });
        request.setNextToken(result.getNextToken());
    } while (!Strings.isNullOrEmpty(request.getNextToken()));
}