use of com.amazonaws.services.ec2.model.DeleteNatGatewayRequest in project photon-model by vmware.
the class AWSRemoteCleanup method deleteNATGateway.
private void deleteNATGateway(String vpcId, AmazonEC2 usEastEc2Client) {
DescribeNatGatewaysRequest natGatewaysRequest = new DescribeNatGatewaysRequest().withFilter(new Filter(VPC_KEY, Collections.singletonList(vpcId)));
DescribeNatGatewaysResult natGatewaysResult = usEastEc2Client.describeNatGateways(natGatewaysRequest);
natGatewaysResult.getNatGateways().forEach(natGateway -> {
DeleteNatGatewayRequest deleteNatGatewayRequest = new DeleteNatGatewayRequest().withNatGatewayId(natGateway.getNatGatewayId());
this.host.log("Terminating stale NAT gateway: %s", natGateway.getNatGatewayId());
usEastEc2Client.deleteNatGateway(deleteNatGatewayRequest);
});
}
use of com.amazonaws.services.ec2.model.DeleteNatGatewayRequest in project photon-model by vmware.
the class AWSNetworkClient method deleteNATGateway.
/**
* Delete a NAT Gateway
* It waits for the NAT gateway to get into the Deleted state before returning.
*/
public DeferredResult<Void> deleteNATGateway(String natGatewayId, TaskManager taskManager, long taskExpirationMicros) {
DeleteNatGatewayRequest req = new DeleteNatGatewayRequest().withNatGatewayId(natGatewayId);
String message = "Delete AWS NAT Gateway with id [" + natGatewayId + "].";
AWSDeferredResultAsyncHandler<DeleteNatGatewayRequest, DeleteNatGatewayResult> handler = new AWSDeferredResultAsyncHandler<>(this.service, message);
this.client.deleteNatGatewayAsync(req, handler);
return handler.toDeferredResult().thenCompose(ignore -> waitForNatGatewayState(natGatewayId, taskManager, taskExpirationMicros, AWSTaskStatusChecker.AWS_DELETED_NAME)).thenApply(ignore -> null);
}
Aggregations