class AwsNetworkConnector implements DefaultNetworkConnector {

    @Override
    public NetworkCidr getNetworkCidr(Network network, CloudCredential credential) {
        AwsCredentialView awsCredentialView = new AwsCredentialView(credential);
        AmazonEC2Client awsClientAccess = awsClient.createAccess(awsCredentialView, network.getStringParameter(AwsNetworkView.REGION));
        AwsNetworkView awsNetworkView = new AwsNetworkView(network);
        String existingVpc = awsNetworkView.getExistingVpc();
        DescribeVpcsResult describeVpcsResult = awsClientAccess.describeVpcs(new DescribeVpcsRequest().withVpcIds(existingVpc));
        List<String> vpcCidrs = new ArrayList<>();
        for (Vpc vpc : describeVpcsResult.getVpcs()) {
            if (vpc.getCidrBlockAssociationSet() != null) {
                LOGGER.info("The VPC {} has associated CIDR block so using the CIDR blocks in the VPC.", vpc.getVpcId());
                List<String> cidrs = vpc.getCidrBlockAssociationSet()
                        .stream()
                        .map(VpcCidrBlockAssociation::getCidrBlock)
                        .collect(Collectors.toList());
                LOGGER.info("The VPC {} CIDRs block are {}.", vpc.getVpcId(), cidrs);
                vpcCidrs.addAll(cidrs);
            } else {
                LOGGER.info("The VPC {} has no associated CIDR block so using the CIDR block in the VPC.", vpc.getVpcId());
                vpcCidrs.add(vpc.getCidrBlock());
            }
        }

        if (vpcCidrs.isEmpty()) {
            throw new BadRequestException("VPC cidr could not fetch from AWS: " + existingVpc);
        }
        if (vpcCidrs.size() > 1) {
            LOGGER.info("More than one vpc cidrs for VPC {}. We will use the first one: {}", existingVpc, vpcCidrs.get(0));
        }
        return new NetworkCidr(vpcCidrs.get(0), vpcCidrs);
    }

}