Search in sources :

Example 1 with DescribeVpnGatewaysRequest

use of com.amazonaws.services.ec2.model.DescribeVpnGatewaysRequest in project photon-model by vmware.

the class AWSRemoteCleanup method deleteVirtualPrivateGateways.

private void deleteVirtualPrivateGateways(String vpcId, AmazonEC2 usEastEc2Client) {
    DescribeVpnGatewaysRequest vpnGatewaysRequest = new DescribeVpnGatewaysRequest().withFilters(new Filter(ATTACHMENT_VPC_KEY, Collections.singletonList(vpcId)));
    DescribeVpnGatewaysResult vpnGatewaysResult = usEastEc2Client.describeVpnGateways(vpnGatewaysRequest);
    vpnGatewaysResult.getVpnGateways().forEach(vpnGateway -> {
        DetachVpnGatewayRequest detachVpnGatewayRequest = new DetachVpnGatewayRequest().withVpnGatewayId(vpnGateway.getVpnGatewayId());
        detachVpnGatewayRequest.setVpcId(vpcId);
        usEastEc2Client.detachVpnGateway(detachVpnGatewayRequest);
        DeleteVpnGatewayRequest deleteVpnGatewayRequest = new DeleteVpnGatewayRequest().withVpnGatewayId(detachVpnGatewayRequest.getVpnGatewayId());
        this.host.log("Terminating stale virtual private gateway: %s", detachVpnGatewayRequest.getVpnGatewayId());
        usEastEc2Client.deleteVpnGateway(deleteVpnGatewayRequest);
    });
}
Also used : DeleteVpnGatewayRequest(com.amazonaws.services.ec2.model.DeleteVpnGatewayRequest) DescribeVpnGatewaysRequest(com.amazonaws.services.ec2.model.DescribeVpnGatewaysRequest) DescribeVpnGatewaysResult(com.amazonaws.services.ec2.model.DescribeVpnGatewaysResult) Filter(com.amazonaws.services.ec2.model.Filter) DetachVpnGatewayRequest(com.amazonaws.services.ec2.model.DetachVpnGatewayRequest)

Aggregations

DeleteVpnGatewayRequest (com.amazonaws.services.ec2.model.DeleteVpnGatewayRequest)1 DescribeVpnGatewaysRequest (com.amazonaws.services.ec2.model.DescribeVpnGatewaysRequest)1 DescribeVpnGatewaysResult (com.amazonaws.services.ec2.model.DescribeVpnGatewaysResult)1 DetachVpnGatewayRequest (com.amazonaws.services.ec2.model.DetachVpnGatewayRequest)1 Filter (com.amazonaws.services.ec2.model.Filter)1