Package overit.geocall.aws.utils
Class AWSUtils
java.lang.Object
overit.geocall.aws.utils.AWSUtils
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 Summary
Modifier and TypeMethodDescriptionstatic software.amazon.awssdk.awscore.client.builder.AwsClientBuilderawsClientBuilderOf(ServiceType serviceType, Company company) static software.amazon.awssdk.awscore.client.builder.AwsClientBuilderawsClientBuilderOf(ServiceType serviceType, Company company, boolean async) static Stringget(Company company, ServiceType serviceType, String key) Returns a string representing the AWS configuration, related to the passed key, associated to aCompanyand a specific service.static software.amazon.awssdk.auth.credentials.AwsCredentialsProvidergetAwsCredentialsProvider(Company company, ServiceType serviceType) Returns an already configuredAwsCredentialsProviderwith which to configure anyAwsClientBuilder.static StringgetEndpoint(Company company, ServiceType serviceType) Returns an AWS Endpoint to override the default one if specified in the configurations.static StringgetRegion(Company company, ServiceType serviceType) Returns a string representing the AWS region associated to aCompanyand a specific service.static software.amazon.awssdk.regions.RegiongetRegion(Company company, ServiceType serviceType, String defaultRegion) Returns the AWSRegionassociated to aCompanyand a specific service.
-
Method Details
-
getAwsCredentialsProvider
public static software.amazon.awssdk.auth.credentials.AwsCredentialsProvider getAwsCredentialsProvider(Company company, ServiceType serviceType) Returns an already configuredAwsCredentialsProviderwith which to configure anyAwsClientBuilder.- Parameters:
company- the company that uses the serviceserviceType- the type of the service- Returns:
- an instance of a configured
AwsCredentialsProvider
-
get
Returns a string representing the AWS configuration, related to the passed key, associated to aCompanyand 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 usedserviceType- the service that must be usedkey- the aws service's key that must be retrieved- Returns:
- the AWS region found
-
getRegion
Returns a string representing the AWS region associated to aCompanyand 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 usedserviceType- 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 AWSRegionassociated to aCompanyand 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 usedserviceType- the service that must be useddefaultRegion- the fallback region if a region is not found- Returns:
- the AWS region
-
getEndpoint
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 usedserviceType- 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 anAwsClientBuilderfor a specificCompanyandServiceType. 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 usedcompany- 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)
-