use of com.amazonaws.services.ec2.model.DeleteInternetGatewayRequest 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.DeleteInternetGatewayRequest in project photon-model by vmware.
the class AWSNetworkClient method deleteInternetGateway.
public void deleteInternetGateway(String resourceID) {
DeleteInternetGatewayRequest req = new DeleteInternetGatewayRequest().withInternetGatewayId(resourceID);
this.client.deleteInternetGateway(req);
}
Aggregations