com.amazonaws.services.ec2.model.Route Java Examples
The following examples show how to use
com.amazonaws.services.ec2.model.Route.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AwsSubnetIgwExplorerTest.java From cloudbreak with Apache License 2.0 | 6 votes |
@Test public void testWithValidIgw() { DescribeRouteTablesResult describeRouteTablesResult = new DescribeRouteTablesResult(); RouteTable routeTable = new RouteTable(); Route route = new Route(); route.setGatewayId(GATEWAY_ID); route.setDestinationCidrBlock(OPEN_CIDR_BLOCK); routeTable.setRoutes(List.of(route)); RouteTableAssociation routeTableAssociation = new RouteTableAssociation(); routeTableAssociation.setSubnetId(SUBNET_ID); routeTable.setAssociations(List.of(routeTableAssociation)); describeRouteTablesResult.setRouteTables(List.of(routeTable)); boolean hasInternetGateway = awsSubnetIgwExplorer.hasInternetGatewayOfSubnet(describeRouteTablesResult, SUBNET_ID); assertTrue(hasInternetGateway); }
Example #2
Source File: AwsSubnetIgwExplorerTest.java From cloudbreak with Apache License 2.0 | 6 votes |
@Test public void testWithVirtualPrivateGateway() { DescribeRouteTablesResult describeRouteTablesResult = new DescribeRouteTablesResult(); RouteTable routeTable = new RouteTable(); Route route = new Route(); route.setGatewayId(VGW_GATEWAY_ID); route.setDestinationCidrBlock(OPEN_CIDR_BLOCK); routeTable.setRoutes(List.of(route)); RouteTableAssociation routeTableAssociation = new RouteTableAssociation(); routeTableAssociation.setSubnetId(SUBNET_ID); routeTable.setAssociations(List.of(routeTableAssociation)); describeRouteTablesResult.setRouteTables(List.of(routeTable)); boolean hasInternetGateway = awsSubnetIgwExplorer.hasInternetGatewayOfSubnet(describeRouteTablesResult, SUBNET_ID); assertFalse(hasInternetGateway); }
Example #3
Source File: AwsSubnetIgwExplorerTest.java From cloudbreak with Apache License 2.0 | 6 votes |
@Test public void testWithIgwButNoAssociation() { DescribeRouteTablesResult describeRouteTablesResult = new DescribeRouteTablesResult(); RouteTable routeTable = new RouteTable(); Route route = new Route(); route.setGatewayId(GATEWAY_ID); route.setDestinationCidrBlock(OPEN_CIDR_BLOCK); routeTable.setRoutes(List.of(route)); RouteTableAssociation routeTableAssociation = new RouteTableAssociation(); routeTableAssociation.setSubnetId(DIFFERENT_SUBNET_ID); routeTable.setAssociations(List.of(routeTableAssociation)); describeRouteTablesResult.setRouteTables(List.of(routeTable)); boolean hasInternetGateway = awsSubnetIgwExplorer.hasInternetGatewayOfSubnet(describeRouteTablesResult, SUBNET_ID); assertFalse(hasInternetGateway); }
Example #4
Source File: RouteTableProvider.java From aws-athena-query-federation with Apache License 2.0 | 5 votes |
/** * Calls DescribeRouteTables on the AWS EC2 Client returning all Routes that match the supplied predicate and attempting * to push down certain predicates (namely queries for specific RoutingTables) to EC2. * * @See TableProvider */ @Override public void readWithConstraint(BlockSpiller spiller, ReadRecordsRequest recordsRequest, QueryStatusChecker queryStatusChecker) { boolean done = false; DescribeRouteTablesRequest request = new DescribeRouteTablesRequest(); ValueSet idConstraint = recordsRequest.getConstraints().getSummary().get("route_table_id"); if (idConstraint != null && idConstraint.isSingleValue()) { request.setRouteTableIds(Collections.singletonList(idConstraint.getSingleValue().toString())); } while (!done) { DescribeRouteTablesResult response = ec2.describeRouteTables(request); for (RouteTable nextRouteTable : response.getRouteTables()) { for (Route route : nextRouteTable.getRoutes()) { instanceToRow(nextRouteTable, route, spiller); } } request.setNextToken(response.getNextToken()); if (response.getNextToken() == null || !queryStatusChecker.isQueryRunning()) { done = true; } } }
Example #5
Source File: RouteTableProvider.java From aws-athena-query-federation with Apache License 2.0 | 5 votes |
/** * Maps an EC2 Route into a row in our Apache Arrow response block(s). * * @param routeTable The RouteTable that owns the given Route. * @param route The Route to map. * @param spiller The BlockSpiller to use when we want to write a matching row to the response. * @note The current implementation is rather naive in how it maps fields. It leverages a static * list of fields that we'd like to provide and then explicitly filters and converts each field. */ private void instanceToRow(RouteTable routeTable, Route route, BlockSpiller spiller) { spiller.writeRows((Block block, int row) -> { boolean matched = true; matched &= block.offerValue("route_table_id", row, routeTable.getRouteTableId()); matched &= block.offerValue("owner", row, routeTable.getOwnerId()); matched &= block.offerValue("vpc", row, routeTable.getVpcId()); matched &= block.offerValue("dst_cidr", row, route.getDestinationCidrBlock()); matched &= block.offerValue("dst_cidr_v6", row, route.getDestinationIpv6CidrBlock()); matched &= block.offerValue("dst_prefix_list", row, route.getDestinationPrefixListId()); matched &= block.offerValue("egress_igw", row, route.getEgressOnlyInternetGatewayId()); matched &= block.offerValue("gateway", row, route.getGatewayId()); matched &= block.offerValue("instance_id", row, route.getInstanceId()); matched &= block.offerValue("instance_owner", row, route.getInstanceOwnerId()); matched &= block.offerValue("nat_gateway", row, route.getNatGatewayId()); matched &= block.offerValue("interface", row, route.getNetworkInterfaceId()); matched &= block.offerValue("origin", row, route.getOrigin()); matched &= block.offerValue("state", row, route.getState()); matched &= block.offerValue("transit_gateway", row, route.getTransitGatewayId()); matched &= block.offerValue("vpc_peering_con", row, route.getVpcPeeringConnectionId()); List<String> associations = routeTable.getAssociations().stream() .map(next -> next.getSubnetId() + ":" + next.getRouteTableId()).collect(Collectors.toList()); matched &= block.offerComplexValue("associations", row, FieldResolver.DEFAULT, associations); List<String> tags = routeTable.getTags().stream() .map(next -> next.getKey() + ":" + next.getValue()).collect(Collectors.toList()); matched &= block.offerComplexValue("tags", row, FieldResolver.DEFAULT, tags); List<String> propagatingVgws = routeTable.getPropagatingVgws().stream() .map(next -> next.getGatewayId()).collect(Collectors.toList()); matched &= block.offerComplexValue("propagating_vgws", row, FieldResolver.DEFAULT, propagatingVgws); return matched ? 1 : 0; }); }
Example #6
Source File: RouteTableProviderTest.java From aws-athena-query-federation with Apache License 2.0 | 5 votes |
private RouteTable makeRouteTable(String id) { RouteTable routeTable = new RouteTable(); routeTable.withRouteTableId(id) .withOwnerId("owner") .withVpcId("vpc") .withAssociations(new RouteTableAssociation().withSubnetId("subnet").withRouteTableId("route_table_id")) .withTags(new Tag("key", "value")) .withPropagatingVgws(new PropagatingVgw().withGatewayId("gateway_id")) .withRoutes(new Route() .withDestinationCidrBlock("dst_cidr") .withDestinationIpv6CidrBlock("dst_cidr_v6") .withDestinationPrefixListId("dst_prefix_list") .withEgressOnlyInternetGatewayId("egress_igw") .withGatewayId("gateway") .withInstanceId("instance_id") .withInstanceOwnerId("instance_owner") .withNatGatewayId("nat_gateway") .withNetworkInterfaceId("interface") .withOrigin("origin") .withState("state") .withTransitGatewayId("transit_gateway") .withVpcPeeringConnectionId("vpc_peering_con") ); return routeTable; }
Example #7
Source File: AwsSubnetIgwExplorer.java From cloudbreak with Apache License 2.0 | 5 votes |
private boolean hasInternetGateway(Optional<RouteTable> rt, String subnetId) { if (rt.isPresent()) { for (Route route : rt.get().getRoutes()) { LOGGER.info("Searching the route which is open. the route is {} and the subnet is :{}", route, subnetId); if (StringUtils.isNotEmpty(route.getGatewayId()) && route.getGatewayId().startsWith(IGW_PREFIX) && OPEN_CIDR_BLOCK.equals(route.getDestinationCidrBlock())) { LOGGER.info("Found the route which is {} and the subnet is :{}", route, subnetId); return true; } } } return false; }
Example #8
Source File: AwsSubnetIgwExplorerTest.java From cloudbreak with Apache License 2.0 | 5 votes |
@Test public void testWithAssociationButNoIgw() { DescribeRouteTablesResult describeRouteTablesResult = new DescribeRouteTablesResult(); RouteTable routeTable = new RouteTable(); Route route = new Route(); routeTable.setRoutes(List.of(route)); RouteTableAssociation routeTableAssociation = new RouteTableAssociation(); routeTableAssociation.setSubnetId(SUBNET_ID); routeTable.setAssociations(List.of(routeTableAssociation)); describeRouteTablesResult.setRouteTables(List.of(routeTable)); boolean hasInternetGateway = awsSubnetIgwExplorer.hasInternetGatewayOfSubnet(describeRouteTablesResult, SUBNET_ID); assertFalse(hasInternetGateway); }
Example #9
Source File: AwsSubnetIgwExplorerTest.java From cloudbreak with Apache License 2.0 | 5 votes |
@Test public void testWithNoAssociationAndNoIgw() { DescribeRouteTablesResult describeRouteTablesResult = new DescribeRouteTablesResult(); RouteTable routeTable = new RouteTable(); Route route = new Route(); routeTable.setRoutes(List.of(route)); RouteTableAssociation routeTableAssociation = new RouteTableAssociation(); routeTableAssociation.setSubnetId(DIFFERENT_SUBNET_ID); routeTable.setAssociations(List.of(routeTableAssociation)); describeRouteTablesResult.setRouteTables(List.of(routeTable)); boolean hasInternetGateway = awsSubnetIgwExplorer.hasInternetGatewayOfSubnet(describeRouteTablesResult, SUBNET_ID); assertFalse(hasInternetGateway); }
Example #10
Source File: AwsSubnetIgwExplorerTest.java From cloudbreak with Apache License 2.0 | 5 votes |
@Test public void testWithRouteButNoAssociations() { DescribeRouteTablesResult describeRouteTablesResult = new DescribeRouteTablesResult(); RouteTable routeTable = new RouteTable(); Route route = new Route(); routeTable.setRoutes(List.of(route)); describeRouteTablesResult.setRouteTables(List.of(routeTable)); boolean hasInternetGateway = awsSubnetIgwExplorer.hasInternetGatewayOfSubnet(describeRouteTablesResult, SUBNET_ID); assertFalse(hasInternetGateway); }
Example #11
Source File: RouteTableImpl.java From aws-sdk-java-resources with Apache License 2.0 | 4 votes |
@Override public List<Route> getRoutes() { return (List<Route>) resource.getAttribute("Routes"); }
Example #12
Source File: RouteTable.java From aws-sdk-java-resources with Apache License 2.0 | 2 votes |
/** * Gets the value of the Routes attribute. If this resource is not yet * loaded, a call to {@code load()} is made to retrieve the value of the * attribute. */ List<Route> getRoutes();