/** * Add a 0.0.0.0/0 route to NAT gateway on an existing route table */ public DeferredResult<Void> addRouteToNatGateway(String routeTableId, String natGatewayId) { CreateRouteRequest req = new CreateRouteRequest() .withNatGatewayId(natGatewayId) .withDestinationCidrBlock(ROUTE_DEST_ALL) .withRouteTableId(routeTableId); String message = "Create AWS Route to NAT Gateway [" + natGatewayId + "] for Internet " + "traffic on route table [" + routeTableId + "]."; AWSDeferredResultAsyncHandler<CreateRouteRequest, CreateRouteResult> handler = new AWSDeferredResultAsyncHandler<>(this.service, message); this.client.createRouteAsync(req, handler); return handler.toDeferredResult() .thenAccept(ignore -> { }); }
/** * Create route with gateway and route table. * * @param routeTableId the route table id * @param gatewayId the gateway id * @param destinationCidrBlock the destination cidr block * @return true if Created Route */ protected final boolean createRoute(final String routeTableId, final String gatewayId, final String destinationCidrBlock) { CreateRouteRequest req = new CreateRouteRequest(); req.setDestinationCidrBlock(destinationCidrBlock); req.setGatewayId(gatewayId); req.setRouteTableId(routeTableId); CreateRouteResult result = amazonEC2Client.createRoute(req); if (result != null) { return true; } return false; }
@Override public CreateRouteResult createRoute(CreateRouteRequest createRouteRequest) throws AmazonServiceException, AmazonClientException { throw new UnsupportedOperationException("Not supported in mock"); }