use of com.amazonaws.services.ec2.model.DetachVpnGatewayRequest 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);
});
}
Aggregations