Example usage for com.amazonaws.services.ec2.model DetachInternetGatewayRequest DetachInternetGatewayRequest

List of usage examples for com.amazonaws.services.ec2.model DetachInternetGatewayRequest DetachInternetGatewayRequest

Introduction

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

Prototype

DetachInternetGatewayRequest

Source Link

Usage

From source file:com.urbancode.terraform.tasks.aws.helpers.AWSHelper.java

License:Apache License

/**
 * Detaches the given internet gateway from the given vpc
 *
 * @param gatewayId//from   ww  w  . ja v a2s . com
 * @param vpcId
 * @param ec2Client
 */
public void detachGateway(String gatewayId, String vpcId, AmazonEC2 ec2Client) {
    try {
        DetachInternetGatewayRequest request = new DetachInternetGatewayRequest()
                .withInternetGatewayId(gatewayId).withVpcId(vpcId);
        ec2Client.detachInternetGateway(request);
    } catch (AmazonServiceException e) {
        log.error("Failed to detach Internet Gateway", e);
        if (!"InvalidInternetGatewayID.NotFound".equalsIgnoreCase(e.getErrorCode())) {
            // only swallow the exception if the gateway id was not found
            throw e;
        }
    }
}

From source file:com.vmware.photon.controller.model.adapters.awsadapter.AWSNetworkService.java

License:Open Source License

public void detachInternetGateway(String vpcID, String gatewayID, AmazonEC2AsyncClient client) {
    DetachInternetGatewayRequest req = new DetachInternetGatewayRequest().withVpcId(vpcID)
            .withInternetGatewayId(gatewayID);
    client.detachInternetGateway(req);// ww w  . j  a v  a2s  .c om
}