Class AWSUtils

java.lang.Object
overit.geocall.aws.utils.AWSUtils

public class AWSUtils extends Object
Utility class that contains some static functions used to fetch the AWS credentials (accessKeyId, secretAccessKey, profile) for a specific service and company. These functions make a series of attempts to fetch the AWS credentials by trying to get the most specific credentials at first, and then, if not found, by trying to fetch a most generic one. In particular, the AwsCredentialsProvider object provided will have its credentials: - taken from the ones specified for the service and for the company (most specific ones); - taken from the ones specified for the company; - taken from the one specified for geocall; - taken from the default AWS Credentials Provider Chain (Working with AWS Credentials)
  • Method Details

    • getAwsCredentialsProvider

      public static software.amazon.awssdk.auth.credentials.AwsCredentialsProvider getAwsCredentialsProvider(Company company, ServiceType serviceType)
      Returns an already configured AwsCredentialsProvider with which to configure any AwsClientBuilder.
      Parameters:
      company - the company that uses the service
      serviceType - the type of the service
      Returns:
      an instance of a configured AwsCredentialsProvider
    • get

      public static String get(Company company, ServiceType serviceType, String key)
      Returns a string representing the AWS configuration, related to the passed key, associated to a Company and a specific service. If configurations related to that service are not found, generic company configuration are taken. If company configurations are not found, more generic configurations are considered. If no configuration is found, null is returned.
      Parameters:
      company - the company for which the information must be used
      serviceType - the service that must be used
      key - the aws service's key that must be retrieved
      Returns:
      the AWS region found
    • getRegion

      public static String getRegion(Company company, ServiceType serviceType)
      Returns a string representing the AWS region associated to a Company and a specific service. If configurations related to that service are not found, generic company configuration are taken. If company configurations are not found, more generic configurations are considered. If no region is found, null is returned.
      Parameters:
      company - the company for which the region information must be used
      serviceType - the service that must be used
      Returns:
      the AWS region found
    • getRegion

      public static software.amazon.awssdk.regions.Region getRegion(Company company, ServiceType serviceType, String defaultRegion)
      Returns the AWS Region associated to a Company and a specific service. If configurations related to that service are not found, generic company configuration are taken. If company configurations are not found, more generic configurations are considered. If no region is found at all, the provided defaultRegion is used.
      Parameters:
      company - the company for which the region information must be used
      serviceType - the service that must be used
      defaultRegion - the fallback region if a region is not found
      Returns:
      the AWS region
    • getEndpoint

      public static String getEndpoint(Company company, ServiceType serviceType)
      Returns an AWS Endpoint to override the default one if specified in the configurations. If configurations related to that service are not found, generic company configuration are taken. If company configurations are not found, more generic configurations are considered. If no endpoint is found at all, null it's returned.
      Parameters:
      company - the company for which the region information must be used
      serviceType - the service that must be used
      Returns:
      the endpoint if specified, null elsewhere
    • awsClientBuilderOf

      public static software.amazon.awssdk.awscore.client.builder.AwsClientBuilder awsClientBuilderOf(ServiceType serviceType, Company company)
      Initialises an AwsClientBuilder for a specific Company and ServiceType. It allows reducing the boilerplate code while creating a new builder by automatically configuring the region, the credentials and the endpoint for a specific AWS service.
      Parameters:
      serviceType - the type of service to be used
      company - the company that uses the service
      Returns:
      the client builder for that service
    • awsClientBuilderOf

      public static software.amazon.awssdk.awscore.client.builder.AwsClientBuilder awsClientBuilderOf(ServiceType serviceType, Company company, boolean async)