Search in sources :

Example 1 with CreateNatGatewayResult

use of com.amazonaws.services.ec2.model.CreateNatGatewayResult in project photon-model by vmware.

the class AWSNetworkClient method createNatGateway.

/**
 * Create a NAT Gateway
 * It waits for the NAT gateway to become available before returning the gateway id.
 */
public DeferredResult<String> createNatGateway(String publicSubnetId, String allocationId, TaskManager taskManager, long taskExpirationMicros) {
    CreateNatGatewayRequest req = new CreateNatGatewayRequest().withSubnetId(publicSubnetId).withAllocationId(allocationId);
    String message = "Create AWS NAT Gateway for subnet [" + publicSubnetId + "] with elastic IP allocation id [" + allocationId + "].";
    AWSDeferredResultAsyncHandler<CreateNatGatewayRequest, CreateNatGatewayResult> handler = new AWSDeferredResultAsyncHandler<>(this.service, message);
    this.client.createNatGatewayAsync(req, handler);
    return handler.toDeferredResult().thenApply(CreateNatGatewayResult::getNatGateway).thenApply(NatGateway::getNatGatewayId).thenCompose(natGatewayId -> waitForNatGatewayState(natGatewayId, taskManager, taskExpirationMicros, AWSTaskStatusChecker.AWS_AVAILABLE_NAME));
}
Also used : CreateNatGatewayRequest(com.amazonaws.services.ec2.model.CreateNatGatewayRequest) CreateNatGatewayResult(com.amazonaws.services.ec2.model.CreateNatGatewayResult)

Aggregations

CreateNatGatewayRequest (com.amazonaws.services.ec2.model.CreateNatGatewayRequest)1 CreateNatGatewayResult (com.amazonaws.services.ec2.model.CreateNatGatewayResult)1