Search in sources :

Example 1 with DescribeNetworkAclsRequest

use of com.amazonaws.services.ec2.model.DescribeNetworkAclsRequest 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);
    });
}
Also used : AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) DescribeNetworkAclsResult(com.amazonaws.services.ec2.model.DescribeNetworkAclsResult) DescribeSubnetsRequest(com.amazonaws.services.ec2.model.DescribeSubnetsRequest) DeleteVpnGatewayRequest(com.amazonaws.services.ec2.model.DeleteVpnGatewayRequest) TerminateInstancesResult(com.amazonaws.services.ec2.model.TerminateInstancesResult) ReleaseAddressRequest(com.amazonaws.services.ec2.model.ReleaseAddressRequest) DescribeSubnetsResult(com.amazonaws.services.ec2.model.DescribeSubnetsResult) CommandLineArgumentParser(com.vmware.xenon.common.CommandLineArgumentParser) Utils(com.vmware.xenon.common.Utils) DescribeNetworkAclsRequest(com.amazonaws.services.ec2.model.DescribeNetworkAclsRequest) DescribeInstancesRequest(com.amazonaws.services.ec2.model.DescribeInstancesRequest) Map(java.util.Map) DescribeNetworkInterfacesResult(com.amazonaws.services.ec2.model.DescribeNetworkInterfacesResult) DeleteSubnetRequest(com.amazonaws.services.ec2.model.DeleteSubnetRequest) Reservation(com.amazonaws.services.ec2.model.Reservation) DeleteVpcRequest(com.amazonaws.services.ec2.model.DeleteVpcRequest) DescribeInternetGatewaysResult(com.amazonaws.services.ec2.model.DescribeInternetGatewaysResult) DescribeVolumesResult(com.amazonaws.services.ec2.model.DescribeVolumesResult) DescribeInstancesResult(com.amazonaws.services.ec2.model.DescribeInstancesResult) AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) DeleteNetworkInterfaceRequest(com.amazonaws.services.ec2.model.DeleteNetworkInterfaceRequest) List(java.util.List) Tag(com.amazonaws.services.ec2.model.Tag) DeleteInternetGatewayRequest(com.amazonaws.services.ec2.model.DeleteInternetGatewayRequest) BasicTestCase(com.vmware.xenon.common.BasicTestCase) HashMap(java.util.HashMap) DeleteNetworkAclRequest(com.amazonaws.services.ec2.model.DeleteNetworkAclRequest) DescribeNetworkInterfacesRequest(com.amazonaws.services.ec2.model.DescribeNetworkInterfacesRequest) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) Regions(com.amazonaws.regions.Regions) DescribeVpcsResult(com.amazonaws.services.ec2.model.DescribeVpcsResult) DisassociateAddressRequest(com.amazonaws.services.ec2.model.DisassociateAddressRequest) DescribeSecurityGroupsResult(com.amazonaws.services.ec2.model.DescribeSecurityGroupsResult) AmazonEC2(com.amazonaws.services.ec2.AmazonEC2) DescribeSecurityGroupsRequest(com.amazonaws.services.ec2.model.DescribeSecurityGroupsRequest) Filter(com.amazonaws.services.ec2.model.Filter) Volume(com.amazonaws.services.ec2.model.Volume) DescribeVpnGatewaysResult(com.amazonaws.services.ec2.model.DescribeVpnGatewaysResult) Instance(com.amazonaws.services.ec2.model.Instance) Before(org.junit.Before) Vpc(com.amazonaws.services.ec2.model.Vpc) DescribeNatGatewaysResult(com.amazonaws.services.ec2.model.DescribeNatGatewaysResult) Test(org.junit.Test) DescribeAddressesRequest(com.amazonaws.services.ec2.model.DescribeAddressesRequest) DetachInternetGatewayRequest(com.amazonaws.services.ec2.model.DetachInternetGatewayRequest) DetachVpnGatewayRequest(com.amazonaws.services.ec2.model.DetachVpnGatewayRequest) TerminateInstancesRequest(com.amazonaws.services.ec2.model.TerminateInstancesRequest) DeleteNatGatewayRequest(com.amazonaws.services.ec2.model.DeleteNatGatewayRequest) Bucket(com.amazonaws.services.s3.model.Bucket) DeleteSecurityGroupRequest(com.amazonaws.services.ec2.model.DeleteSecurityGroupRequest) DescribeNatGatewaysRequest(com.amazonaws.services.ec2.model.DescribeNatGatewaysRequest) TimeUnit(java.util.concurrent.TimeUnit) DescribeVpnGatewaysRequest(com.amazonaws.services.ec2.model.DescribeVpnGatewaysRequest) DeleteVolumeRequest(com.amazonaws.services.ec2.model.DeleteVolumeRequest) DescribeAddressesResult(com.amazonaws.services.ec2.model.DescribeAddressesResult) Collections(java.util.Collections) DescribeInternetGatewaysRequest(com.amazonaws.services.ec2.model.DescribeInternetGatewaysRequest) DeleteNetworkAclRequest(com.amazonaws.services.ec2.model.DeleteNetworkAclRequest) DescribeNetworkAclsRequest(com.amazonaws.services.ec2.model.DescribeNetworkAclsRequest) Filter(com.amazonaws.services.ec2.model.Filter) DescribeNetworkAclsResult(com.amazonaws.services.ec2.model.DescribeNetworkAclsResult)

Aggregations

Regions (com.amazonaws.regions.Regions)1 AmazonEC2 (com.amazonaws.services.ec2.AmazonEC2)1 DeleteInternetGatewayRequest (com.amazonaws.services.ec2.model.DeleteInternetGatewayRequest)1 DeleteNatGatewayRequest (com.amazonaws.services.ec2.model.DeleteNatGatewayRequest)1 DeleteNetworkAclRequest (com.amazonaws.services.ec2.model.DeleteNetworkAclRequest)1 DeleteNetworkInterfaceRequest (com.amazonaws.services.ec2.model.DeleteNetworkInterfaceRequest)1 DeleteSecurityGroupRequest (com.amazonaws.services.ec2.model.DeleteSecurityGroupRequest)1 DeleteSubnetRequest (com.amazonaws.services.ec2.model.DeleteSubnetRequest)1 DeleteVolumeRequest (com.amazonaws.services.ec2.model.DeleteVolumeRequest)1 DeleteVpcRequest (com.amazonaws.services.ec2.model.DeleteVpcRequest)1 DeleteVpnGatewayRequest (com.amazonaws.services.ec2.model.DeleteVpnGatewayRequest)1 DescribeAddressesRequest (com.amazonaws.services.ec2.model.DescribeAddressesRequest)1 DescribeAddressesResult (com.amazonaws.services.ec2.model.DescribeAddressesResult)1 DescribeInstancesRequest (com.amazonaws.services.ec2.model.DescribeInstancesRequest)1 DescribeInstancesResult (com.amazonaws.services.ec2.model.DescribeInstancesResult)1 DescribeInternetGatewaysRequest (com.amazonaws.services.ec2.model.DescribeInternetGatewaysRequest)1 DescribeInternetGatewaysResult (com.amazonaws.services.ec2.model.DescribeInternetGatewaysResult)1 DescribeNatGatewaysRequest (com.amazonaws.services.ec2.model.DescribeNatGatewaysRequest)1 DescribeNatGatewaysResult (com.amazonaws.services.ec2.model.DescribeNatGatewaysResult)1 DescribeNetworkAclsRequest (com.amazonaws.services.ec2.model.DescribeNetworkAclsRequest)1