Example usage for com.amazonaws.services.ec2 AmazonEC2 deleteInternetGateway

List of usage examples for com.amazonaws.services.ec2 AmazonEC2 deleteInternetGateway

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2 AmazonEC2 deleteInternetGateway.

Prototype

DeleteInternetGatewayResult deleteInternetGateway(DeleteInternetGatewayRequest deleteInternetGatewayRequest);

Source Link

Document

Deletes the specified internet gateway.

Usage

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

License:Apache License

/**
 * Deletes the given internetGateway. Does not detach the gateway if it is attached.
 *
 * @param gatewayId//from  ww w  .  j av a2s  .  c om
 * @param ec2Client
 */
public void deleteInternetGateway(String gatewayId, AmazonEC2 ec2Client) {
    try {
        DeleteInternetGatewayRequest request = new DeleteInternetGatewayRequest()
                .withInternetGatewayId(gatewayId);
        ec2Client.deleteInternetGateway(request);
    } catch (AmazonServiceException e) {
        log.error("Failed to delete Internet Gateway", e);
        if (!"InvalidInternetGatewayID.NotFound".equalsIgnoreCase(e.getErrorCode())) {
            // swallow the exception only if the gateway id was not found
            throw e;
        }
    }
}