List of usage examples for com.amazonaws.services.ec2.model AttachInternetGatewayRequest AttachInternetGatewayRequest
AttachInternetGatewayRequest
From source file:com.urbancode.terraform.tasks.aws.helpers.AWSHelper.java
License:Apache License
/** * Attaches the given gateway to the given Vpc. * * @param gatewayId/*from www . j av a 2s. 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; } } }
From source file:com.vmware.photon.controller.model.adapters.awsadapter.AWSNetworkService.java
License:Open Source License
public void attachInternetGateway(String vpcID, String gatewayID, AmazonEC2AsyncClient client) { AttachInternetGatewayRequest req = new AttachInternetGatewayRequest().withVpcId(vpcID) .withInternetGatewayId(gatewayID); client.attachInternetGateway(req);// w w w .j av a2 s.c om }