use of com.amazonaws.services.ec2.model.DetachInternetGatewayRequest in project photon-model by vmware.
the class AWSRemoteCleanup method deleteInternetGateways.
private void deleteInternetGateways(String vpcId, AmazonEC2 usEastEc2Client) {
DescribeInternetGatewaysRequest internetGatewaysRequest = new DescribeInternetGatewaysRequest().withFilters(new Filter(ATTACHMENT_VPC_KEY, Collections.singletonList(vpcId)));
DescribeInternetGatewaysResult internetGatewaysResult = usEastEc2Client.describeInternetGateways(internetGatewaysRequest);
internetGatewaysResult.getInternetGateways().forEach(internetGateway -> {
DetachInternetGatewayRequest detachInternetGatewayRequest = new DetachInternetGatewayRequest().withInternetGatewayId(internetGateway.getInternetGatewayId());
detachInternetGatewayRequest.setVpcId(vpcId);
usEastEc2Client.detachInternetGateway(detachInternetGatewayRequest);
DeleteInternetGatewayRequest deleteInternetGatewayRequest = new DeleteInternetGatewayRequest().withInternetGatewayId(internetGateway.getInternetGatewayId());
this.host.log("Terminating stale internet gateway: %s", internetGateway.getInternetGatewayId());
usEastEc2Client.deleteInternetGateway(deleteInternetGatewayRequest);
});
}
use of com.amazonaws.services.ec2.model.DetachInternetGatewayRequest in project photon-model by vmware.
the class AWSNetworkClient method detachInternetGateway.
public void detachInternetGateway(String vpcId, String gatewayId) {
DetachInternetGatewayRequest req = new DetachInternetGatewayRequest().withVpcId(vpcId).withInternetGatewayId(gatewayId);
this.client.detachInternetGateway(req);
}
Aggregations