use of com.amazonaws.services.ec2.model.ServiceDetail in project cloudbreak by hortonworks.
the class AwsNetworkCfTemplateProvider method createInterfaceServiceEndpoints.
private List<AwsServiceEndpointView> createInterfaceServiceEndpoints(NetworkCreationRequest networkCreationRequest, List<SubnetRequest> subnets) {
Map<String, String> endpointNameMappings = interfaceServices.stream().collect(Collectors.toMap(s -> String.format(VPC_INTERFACE_SERVICE_ENDPOINT_NAME_PATTERN, networkCreationRequest.getRegion().value(), s), s -> s));
List<ServiceDetail> serviceDetails = describeVpcServiceDetails(networkCreationRequest, endpointNameMappings);
Map<String, SubnetRequest> subnetByZoneMap = createPublicSubnetByZoneMap(subnets);
List<AwsServiceEndpointView> interfaceServceEndpoints = new ArrayList<>();
for (ServiceDetail serviceDetail : serviceDetails) {
List<SubnetRequest> subnetRequests = serviceDetail.getAvailabilityZones().stream().filter(az -> subnetByZoneMap.containsKey(az)).map(az -> subnetByZoneMap.get(az)).collect(Collectors.toList());
if (!subnetRequests.isEmpty()) {
interfaceServceEndpoints.add(new AwsServiceEndpointView(endpointNameMappings.get(serviceDetail.getServiceName()), subnetRequests));
}
}
return interfaceServceEndpoints;
}
use of com.amazonaws.services.ec2.model.ServiceDetail in project cloudbreak by hortonworks.
the class AwsNetworkCfTemplateProviderTest method createDescribeVpcEndpointServicesResultWithDifferentAzs.
private static DescribeVpcEndpointServicesResult createDescribeVpcEndpointServicesResultWithDifferentAzs() {
DescribeVpcEndpointServicesResult describeVpcEndpointServicesResult = new DescribeVpcEndpointServicesResult();
List<ServiceDetail> serviceDetails = new ArrayList<>();
ServiceDetail serviceDetail1 = new ServiceDetail().withServiceName(String.format(AwsNetworkCfTemplateProvider.VPC_INTERFACE_SERVICE_ENDPOINT_NAME_PATTERN, "region", "interface1"));
serviceDetail1.setAvailabilityZones(List.of("az1"));
serviceDetails.add(serviceDetail1);
ServiceDetail serviceDetail2 = new ServiceDetail().withServiceName(String.format(AwsNetworkCfTemplateProvider.VPC_INTERFACE_SERVICE_ENDPOINT_NAME_PATTERN, "region", "interface2"));
serviceDetail2.setAvailabilityZones(List.of("az2", "az3"));
serviceDetails.add(serviceDetail2);
ServiceDetail serviceDetail3 = new ServiceDetail().withServiceName(String.format(AwsNetworkCfTemplateProvider.VPC_INTERFACE_SERVICE_ENDPOINT_NAME_PATTERN, "region", "interface3"));
serviceDetail3.setAvailabilityZones(List.of("az5", "az6"));
serviceDetails.add(serviceDetail3);
describeVpcEndpointServicesResult.setServiceDetails(serviceDetails);
return describeVpcEndpointServicesResult;
}
use of com.amazonaws.services.ec2.model.ServiceDetail in project cloudbreak by hortonworks.
the class AwsNetworkCfTemplateProviderTest method createDescribeVpcEndpointServicesResult.
private static DescribeVpcEndpointServicesResult createDescribeVpcEndpointServicesResult(String... services) {
DescribeVpcEndpointServicesResult describeVpcEndpointServicesResult = new DescribeVpcEndpointServicesResult();
List<ServiceDetail> serviceDetails = new ArrayList<>();
for (String service : services) {
ServiceDetail serviceDetail = new ServiceDetail().withServiceName(String.format(AwsNetworkCfTemplateProvider.VPC_INTERFACE_SERVICE_ENDPOINT_NAME_PATTERN, "region", service));
serviceDetail.setAvailabilityZones(List.of("az1", "az2"));
serviceDetails.add(serviceDetail);
}
describeVpcEndpointServicesResult.setServiceDetails(serviceDetails);
return describeVpcEndpointServicesResult;
}
use of com.amazonaws.services.ec2.model.ServiceDetail in project cloudbreak by hortonworks.
the class AwsNetworkCfTemplateProvider method describeVpcServiceDetails.
private List<ServiceDetail> describeVpcServiceDetails(NetworkCreationRequest networkCreationRequest, Map<String, String> endpointNameMappings) {
AwsCredentialView awsCredential = new AwsCredentialView(networkCreationRequest.getCloudCredential());
AmazonEc2Client awsClientAccess = awsClient.createEc2Client(awsCredential, networkCreationRequest.getRegion().value());
return awsClientAccess.describeVpcEndpointServices().getServiceDetails().stream().filter(sd -> endpointNameMappings.containsKey(sd.getServiceName())).collect(Collectors.toList());
}
Aggregations