List of usage examples for com.amazonaws.services.ec2 AmazonEC2 attachInternetGateway
AttachInternetGatewayResult attachInternetGateway(AttachInternetGatewayRequest attachInternetGatewayRequest);
Attaches an internet gateway to a VPC, enabling connectivity between the internet and the VPC.
From source file:com.urbancode.terraform.tasks.aws.helpers.AWSHelper.java
License:Apache License
/** * Attaches the given gateway to the given Vpc. * * @param gatewayId//ww w. j a va2 s .c o m * @param vpcId * @param ec2Client */ public void attachInternetGatewayToVpc(String gatewayId, String vpcId, AmazonEC2 ec2Client) { try { AttachInternetGatewayRequest request = new AttachInternetGatewayRequest() .withInternetGatewayId(gatewayId).withVpcId(vpcId); ec2Client.attachInternetGateway(request); } catch (AmazonServiceException e) { log.error("Failed to attach Internet Gateway to Vpc", e); if ("InvalidVpcID.NotFound".equalsIgnoreCase(e.getErrorCode())) { // could not find vpc log.error("Vpc " + vpcId + " not found."); } else if ("InvalidInternetGatewayID.NotFound".equalsIgnoreCase(e.getErrorCode())) { // swallow the exception only if the gateway id was not found log.error("Internet Gateway " + gatewayId + " not found."); } else { throw e; } } }