List of usage examples for com.amazonaws.services.ec2 AmazonEC2 detachInternetGateway
DetachInternetGatewayResult detachInternetGateway(DetachInternetGatewayRequest detachInternetGatewayRequest);
Detaches an internet gateway from a VPC, disabling connectivity between the internet and the VPC.
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 w ww. j a v a2 s. co m*/ * @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; } } }