Sprinkle Docs
Search…
AWS Athena
Guide to integrate your Athena with Sprinkle
This page covers the details about integrating Athena with Sprinkle.
When setting up Athena connection, Sprinkle additionally requires a S3 bucket. This guide covers the role of all the components and steps to setup.
  • ​Integrating Athena: All analytical data is stored and queried from Athena warehouse
  • ​Create S3 Bucket: Sprinkle stores all intermediate data and report caches in this bucket

Step by Step Guides

Integrating Athena

STEP-1: Configure Athena output location

Configure in the AWS Athena Portal

STEP-2: Configure Athena Connection

  • Log into Sprinkle application
  • Navigate to Admin -> Drivers -> New Warehouse
  • Select Athena
  • Provide all the mandatory details
    • Distinct Name: Name to identify this connection
    • JDBC URL : Url will of the following format -> jdbc:awsathena://athena.<REGION>.amazonaws.com:443/
      Example: jdbc:awsathena://athena.ap-south-1.amazonaws.com:443/
    • API Key
    • Secret Key
    • S3 Output Location: location configured in STEP-1
    • Schema
  • Test Connection
  • Create

Create S3 Bucket

S3 bucket is required to store intermediate data and report outputs. Refer here for creating S3 bucket and configuring it in Sprinkle

Athena Output Purging: Setup

  1. 1.
    Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/.
  2. 2.
    In the Buckets list, choose the name of the bucket that you want to create a lifecycle rule for.
  3. 3.
    Choose the Management tab, and select Create lifecycle rule.
  4. 4.
    In the Lifecycle rule name, enter a name for your rule. The name must be unique within the bucket.
  5. 5.
    Choose the scope of the lifecycle rule as Limit the scope of this rule using one or more filters. To limit the scope by prefix, in Prefix, enter the prefix. (Folder name which we specified in Athena Query result location)
  6. 6.
    Under Lifecycle rule actions, choose the following actions that this lifecycle rule will perform:
    1. 1.
      Expire current versions of objects
    2. 2.
      Permanently delete previous versions of objects
  7. 7.
    To expire current versions of objects, under Expire current versions of objects, in the Number of days after object creation, enter the number of days as 1.
  8. 8.
    To permanently delete previous versions of objects, under Permanently delete previous versions of objects, in the Number of days after objects become previous versions, enter the number of days as 1.
  9. 9.
    Verify the rule once again and choose Create rule.
  10. 10.
    The created rule will appear in the Life cycle rules.

Database Level Access in Athena: Setup

The following procedure can help to create Athena dB and provide access to the particular dB in Sprinkle. It will also help to share Athena across different organizations without sharing the same credentials.

Steps to be followed

  1. 1.
    Create a new database in Athena
  2. 2.
    Create IAM Policy
  3. 3.
    Create IAM User
  4. 4.
    Create Access key
  5. 5.
    Update Sprinkle driver

Create Athena Database

  1. 1.
    Log in to the AWS console and go to Athena.
  2. 2.
    Run the create database command in the query editor by updating dB name. CREATE DATABASE <DB_NAME>

Create IAM Policy

  1. 1.
    Log in to the AWS console, go to IAM and select Policy from the left pane.
  2. 2.
    Click on Creare policy and go to the JSON tab.
  3. 3.
    Paste the following policy in the editor with updating region, database name, account number and S3 bucket name.

Access Policy

1
{
2
"Version": "2012-10-17",
3
"Statement": [
4
{
5
"Sid": "VisualEditor0",
6
"Effect": "Allow",
7
"Action": [
8
"glue:GetDatabase",
9
"glue:GetDatabases",
10
"glue:GetPartition",
11
"glue:CreateTable",
12
"glue:GetTables",
13
"glue:GetPartitions",
14
"glue:CreateDatabase",
15
"glue:UpdateTable",
16
"glue:DeleteTable",
17
"glue:CreatePartition",
18
"glue:DeletePartition",
19
"glue:UpdatePartition",
20
"glue:GetTable",
21
"athena:StartQueryExecution",
22
"athena:GetQueryExecution",
23
"athena:GetQueryResults"
24
],
25
"Resource": [
26
"arn:aws:glue:<REGION>:<ACCOUNT_NO>:catalog",
27
"arn:aws:glue:<REGION>:<ACCOUNT_NO>:database/<DB_NAME>",
28
"arn:aws:glue:<REGION>:<ACCOUNT_NO>table/<DB_NAME>/*",
29
"arn:aws:athena:<REGION>:<ACCOUNT_NO>:workgroup/primary"
30
]
31
},
32
{
33
"Effect": "Allow",
34
"Action": [
35
"s3:PutObject",
36
"s3:GetObject",
37
"s3:ListBucketMultipartUploads",
38
"s3:ListBucket",
39
"s3:DeleteObject",
40
"s3:GetBucketLocation",
41
"s3:ListMultipartUploadParts"
42
],
43
"Resource": [
44
"arn:aws:s3:::<BUCKET_NAME>/*",
45
"arn:aws:s3:::<BUCKET_NAME>"
46
]
47
}
48
]
49
}
Copied!

Create IAM user

  1. 1.
    Log in to the AWS console, go to IAM and select User from the left pane.
  2. 2.
    Click on Add User, provide the User name and select access type as Programmatic Access.
  3. 3.
    Attach the policy created for Athena access from Attach existing policy directly.

Create Access key

  1. 1.
    Go to the IAM users and select the newly created user.
  2. 2.
    Goto Security Credentials tab and click on create access key.
  3. 3.
    This will create the access key. Download the CSV file and click on show secret to copy the secret.