Class AWSGeneralUtil

  • Direct Known Subclasses:
    AWSClientUtil

    @Internal
    public class AWSGeneralUtil
    extends Object
    Some general utilities specific to Amazon Web Service.
    • Constructor Detail

      • AWSGeneralUtil

        public AWSGeneralUtil()
    • Method Detail

      • getCredentialProviderType

        public static AWSConfigConstants.CredentialProvider getCredentialProviderType​(Properties configProps,
                                                                                      String configPrefix)
        Determines and returns the credential provider type from the given properties.
        Returns:
        the credential provider type
      • getCredentialsProvider

        public static software.amazon.awssdk.auth.credentials.AwsCredentialsProvider getCredentialsProvider​(Map<String,​?> configProps)
        Return a AwsCredentialsProvider instance corresponding to the configuration properties.
        Parameters:
        configProps - the configuration property map
        Returns:
        The corresponding AWS Credentials Provider instance
      • getCredentialsProvider

        public static software.amazon.awssdk.auth.credentials.AwsCredentialsProvider getCredentialsProvider​(Properties configProps)
        Return a AwsCredentialsProvider instance corresponding to the configuration properties.
        Parameters:
        configProps - the configuration properties
        Returns:
        The corresponding AWS Credentials Provider instance
      • getCredentialsProvider

        public static software.amazon.awssdk.auth.credentials.AwsCredentialsProvider getCredentialsProvider​(Properties configProps,
                                                                                                            String configPrefix)
      • getCustomCredentialProvider

        public static software.amazon.awssdk.auth.credentials.AwsCredentialsProvider getCustomCredentialProvider​(Properties conf,
                                                                                                                 String confKey)
        Tries to instantiate the user's custom AWS credential provider class.
        Parameters:
        conf - Properties object that contains all the provided config and that we pass down to the custom credential provider implementation's constructor
        confKey - Config key we use to retrieve the credential provider class name specified by the user
        Returns:
        an AwsCredentialsProvider object
        Throws:
        ClassCastException - if the specified class does not implement AwsCredentialsProvider
        RuntimeException - if the specified class does not exist or does not have a constructor with signature `MyCustomCredentialsClass(Properties props)`.
      • getProfileCredentialProvider

        public static software.amazon.awssdk.auth.credentials.AwsCredentialsProvider getProfileCredentialProvider​(Properties configProps,
                                                                                                                  String configPrefix)
      • createAsyncHttpClient

        public static software.amazon.awssdk.http.async.SdkAsyncHttpClient createAsyncHttpClient​(Properties configProperties)
      • createAsyncHttpClient

        public static software.amazon.awssdk.http.async.SdkAsyncHttpClient createAsyncHttpClient​(Properties configProperties,
                                                                                                 software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient.Builder httpClientBuilder)
      • createAsyncHttpClient

        public static software.amazon.awssdk.http.async.SdkAsyncHttpClient createAsyncHttpClient​(software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient.Builder httpClientBuilder)
      • createAsyncHttpClient

        public static software.amazon.awssdk.http.async.SdkAsyncHttpClient createAsyncHttpClient​(software.amazon.awssdk.utils.AttributeMap config,
                                                                                                 software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient.Builder httpClientBuilder)
      • createSyncHttpClient

        public static software.amazon.awssdk.http.SdkHttpClient createSyncHttpClient​(software.amazon.awssdk.utils.AttributeMap config,
                                                                                     software.amazon.awssdk.http.apache.ApacheHttpClient.Builder httpClientBuilder)
      • getRegion

        public static software.amazon.awssdk.regions.Region getRegion​(Properties configProps)
        Creates a Region object from the given Properties.
        Parameters:
        configProps - the properties containing the region
        Returns:
        the region specified by the properties
      • getStsEndpoint

        public static URI getStsEndpoint​(Properties configProps)
        Creates STS endpoint URI object from the given Properties.
        Parameters:
        configProps - the properties containing the endpoint
        Returns:
        STS endpoint URI specified by the properties, or null if endpoint not specified
      • isValidRegion

        public static boolean isValidRegion​(software.amazon.awssdk.regions.Region region)
        Checks whether or not a region is valid.
        Parameters:
        region - The AWS region to check
        Returns:
        true if the supplied region is valid, false otherwise
      • validateAwsConfiguration

        public static void validateAwsConfiguration​(Properties config)
        Validates configuration properties related to Amazon AWS service.
        Parameters:
        config - the properties to setup credentials and region
      • closeResources

        public static void closeResources​(software.amazon.awssdk.utils.SdkAutoCloseable... resources)
      • validateAwsCredentials

        public static void validateAwsCredentials​(Properties config)