aws-samples / aws-blog-athena-custom-jdbc-credentials

The repository demonstrates use cases for running queries using Athena utilizing a custom JDBC credentials provider
MIT No Attribution
9 stars 10 forks source link

Connecting to Amazon Athena with Federated Identities using Temporary Credentials

Using temporary security credentials ensures that access keys to protected resources in production are not directly hard-coded in the applications. Instead, you rely on AWS Secure Token Service (AWS STS) to generate temporary credentials. Temporary security credentials work similar to the long-term access key credentials that your Amazon IAM users can use, with the following differences. These credentials are:

We list below some of the typical use cases in which your organization may require federated access to Amazon Athena:

  1. Running Queries in Amazon Athena while Using Federation via SAML with Active Directory (AD). Your group requires to run queries in Amazon Athena while federating into AWS using SAML with permissions stored in AD.
  2. Enabling Cross-Account Access to Amazon Athena for Users in Your Organization. A member of your group with access to AWS Account “A” needs to run Athena queries in Account “B”.
  3. Enabling Access to Amazon Athena for a Data Application. A data application deployed on an Amazon EC2 instance needs to run Amazon Athena queries via JDBC.

Pre-requisites

SQL Workbench Extended Properties for SAML generated credentials

Property Value
AwsCredentialsProviderClass com.amazonaws.athena.jdbc.CustomIAMRoleAssumptionSAMLCredentialsProvider
AwsCredentialsProviderArguments access_key_id,secret_access_key,session token
S3OutputLocation s3://bucket where athena results are stored
LogPath local path on laptop or pc where logs are stored
LogLevel LogLevel 1 thru 6

SQL Workbench Extended Properties for Cross-Account Role Access

Property Value
AwsCredentialsProviderClass com.amazonaws.athena.jdbc.CustomIAMRoleAssumptionCredentialsProvider
AwsCredentialsProviderArguments access_key_id,secret_access_key,Cross Account Role ARN
S3OutputLocation s3://bucket where athena results are stored
LogPath local path on laptop or pc where logs are stored
LogLevel LogLevel 1 thru 6

SQL Workbench Extended Properties for EC2 Instance role

Property Value
AwsCredentialsProviderClass com.simba.athena.amazonaws.auth.InstanceProfileCredentialsProvider
S3OutputLocation s3://bucket where athena results are stored
LogPath local path on laptop or pc where logs are stored
LogLevel LogLevel 1 thru 6