use of com.amazonaws.services.ec2.model.DescribeNetworkAclsResult in project photon-model by vmware.
the class AWSRemoteCleanup method disassociateAndDeleteNetworkACLs.
private void disassociateAndDeleteNetworkACLs(String vpcId, AmazonEC2 usEastEc2Client) {
DescribeNetworkAclsRequest networkAclsRequest = new DescribeNetworkAclsRequest().withFilters(new Filter(VPC_KEY, Collections.singletonList(vpcId)));
DescribeNetworkAclsResult networkAclsResult = usEastEc2Client.describeNetworkAcls(networkAclsRequest);
networkAclsResult.getNetworkAcls().stream().filter(networkAcl -> !(networkAcl.getIsDefault())).forEach(networkAcl -> {
DeleteNetworkAclRequest deleteNetworkAclRequest = new DeleteNetworkAclRequest().withNetworkAclId(networkAcl.getNetworkAclId());
this.host.log("Terminating stale network acl: %s", networkAcl.getNetworkAclId());
usEastEc2Client.deleteNetworkAcl(deleteNetworkAclRequest);
});
}
Aggregations