Search in sources :

Example 1 with DeleteInternetGatewayRequest

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);
    });
}
Also used : DescribeInternetGatewaysResult(com.amazonaws.services.ec2.model.DescribeInternetGatewaysResult) DeleteInternetGatewayRequest(com.amazonaws.services.ec2.model.DeleteInternetGatewayRequest) Filter(com.amazonaws.services.ec2.model.Filter) DetachInternetGatewayRequest(com.amazonaws.services.ec2.model.DetachInternetGatewayRequest) DescribeInternetGatewaysRequest(com.amazonaws.services.ec2.model.DescribeInternetGatewaysRequest)

Example 2 with 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);
}
Also used : DeleteInternetGatewayRequest(com.amazonaws.services.ec2.model.DeleteInternetGatewayRequest)

Aggregations

DeleteInternetGatewayRequest (com.amazonaws.services.ec2.model.DeleteInternetGatewayRequest)2 DescribeInternetGatewaysRequest (com.amazonaws.services.ec2.model.DescribeInternetGatewaysRequest)1 DescribeInternetGatewaysResult (com.amazonaws.services.ec2.model.DescribeInternetGatewaysResult)1 DetachInternetGatewayRequest (com.amazonaws.services.ec2.model.DetachInternetGatewayRequest)1 Filter (com.amazonaws.services.ec2.model.Filter)1