- Set the
AwsCredentialsProviderClass
property to a fully qualified class name that implements the AWSCredentialsProvider interface. This class can be an implementation from the AWS SDK, or a custom implementation.
Note: The AWS SDK is shaded and packaged in the connector JAR file. However, if your project has its own AWS SDK dependency, it is recommended that you use that class implementation instead of the one that is shaded in the connector. The shaded AWS SDK is intended to be used internally by the connector, and might not be optimal for other use cases.
- If necessary, set the
AwsCredentialsProviderArguments
property to a comma-separated list of String arguments for the constructor of the AwsCredentialsProviderClass.
- The connector only supports String arguments for the constructor parameters.
- Multiple arguments must be separated by a comma (
,
). - Surrounding spaces are not included in the parsed arguments.
- To escape a single character, use a backslash (
\
) before that character. To indicate a backslash in an argument, use two backslashes (\\
). - To escape all commas in an argument, enclose the argument in quotation marks (
"
). To indicate a quotation mark in a quoted argument, use a backslash (\
) before that quotation mark.
- Using DefaultAWSCredentialsProviderChain
- Using PropertiesFileCredentialsProvider
- Using InstanceProfileCredentialsProvider
- Using a Custom Credentials Provider
Using DefaultAWSCredentialsProviderChain
To configure authentication using DefaultAWSCredentialsProviderChain:- Set the
AwsCredentialsProviderClass
property tocom.simba.athena.amazonaws.auth.DefaultAWSCredentialsProviderChain
. - Do not set the
AwsCredentialsProviderArguments
property.
Using PropertiesFileCredentialsProvider
To configure authentication using PropertiesFileCredentialsProvider:- Create a text file called
athenaCredentials.props
. This file should contain the following text:
- [AccessKey] is the access key provided by your AWS account.
- [SecretKey] is the secret key provided by your AWS account.
- Set the
AwsCredentialsProviderClass
property tocom.simba.athena.amazonaws.auth.PropertiesFileCredentialsProvider
. - Set the
AwsCredentialsProviderArguments
property to the full path and name of theathenaCredentials.props
file. For example,"/Users/skroob/athenaCredentials.props"
.
Using InstanceProfileCredentialsProvider
To configure authentication using InstanceProfileCredentialsProvider:- Set the
AwsCredentialsProviderClass
property tocom.simba.athena.amazonaws.auth.InstanceProfileCredentialsProvider
. - Do not set the
AwsCredentialsProviderArguments
property.
Example: Using a Profile to Provide a Session Token
This example demonstrates how to authenticate a connection to Athena using a profile that provides a session token. A session token grants temporary access to the Athena service. An access key and secret key must be provided along with the token. First, define a profile that specifies the access key, secret key, and session token. For example:- Set the
AwsCredentialsProviderClass
property tocom.simba.athena.amazonaws.auth.profile.ProfileCredentialsProvider
. - Set the
AwsCredentialsProviderArguments
property to the name of the profile that you want to use. In this case,simba_session
.
Example: Using a Profile to Switch Roles
You can define a profile that refers to another existing profile, and then include an additional role setting. When you use this profile to authenticate your connection, the connector uses all the settings defined in the referenced profile as well as the role that has been additionally specified. By switching between these profiles, you can alternate between your roles without having to update the profile definition each time. For an example that demonstrates how to configure profiles this way, see “Example Scenario: Switch to a Production Role” in the AWS Identity and Access Management documentation: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-cli.html#switch-role-cli-scenario-prod-env. Based on this AWS example, which involves defining a main profile nameddefault
and a role switch profile named prodaccess
, in order to switch roles when using the Simba Amazon Athena JDBC Connector, all you would need to do is update the AwsCredentialsProviderArguments
setting in your connection URL. For example:
- To use the
ProductionAccessRole
role:
- Or, to access Athena without using the
ProductionAccessRole
role:
Using a Custom Credentials Provider
This example shows a custom credentials provider, CustomSessionsCredentialsProvider, that uses an access and secret key in addition to a session token. CustomSessionsCredentialsProvider is shown for example only and is not included in the connector. You must create custom providers before you can use them. For an example of using a custom credentials provider to obtain credentials from an identity provider, see Using a Custom Credentials Provider for an Identity Provider. To configure authentication using a custom credentials provider:- Create a credentials provider called CustomSessionsCredentialsProvider that uses an access key, secret key, and session token for authentication.
- In the connection URL, set the
AwsCredentialsProviderClass
property tocom.example.CustomSessionCredentialsProvider
. - Set the
AwsCredentialsProviderArguments
property to"My_Access_Key, My_Secret_Key, My_Token"
. - Generate My_Access_Key, My_Secret_Key and My_Token using AWS Security Token Service. For detailed instructions, see “Temporary Security Credentials” in the AWS Identity and Access Management User Guide : http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html.