Amazon Athena

Create an Amazon Athena Datasource

  1. Navigate to: Resources > Data Sources

  2. Select the Amazon Athena Icon:

Data Source Inputs

  • Name (required)

  • Description (optional)

  • Region name (required):

    • This should correspond to the region where your data is stored in S3

    • Example: us-west-1

  • Credential Type: See Data Source Security​

  • Access key ID:

  • Secret access key:

Use Amazon Athena

Read

Python
Python
%python
​
# Connect to Athena. Returns: botocore.client.Athena object
client = z.getDatasource("zepl_docs_athena")
​
# Set parameter values for query execution
params = {
'region': 'us-west-1',
'database': 'default',
'bucket': 'shainsky-athena-demo',
'path': 'athena_queries',
'query': ( """ SELECT os, COUNT(*) count
FROM default.cloudfront_logs
WHERE date BETWEEN date '2014-07-05' AND date '2014-08-05'
GROUP BY os
""")
}
​
# Execute query in athena and return result files to the S3 bucket specificed at OutputLocation path
response = client.start_query_execution(
QueryString=params['query'],
QueryExecutionContext={
'Database': params['database']
},
ResultConfiguration={
'OutputLocation': 's3://' + params['bucket'] + '/' + params['path']
}
)

Use z.getDatasource() to return Botocore Athena client object: botocore.client.Athena​

Configure Authentication

  1. Login to AWS

  2. Navigate to IAM > Users

  3. Select your user name

  4. Select Add permissions, to make sure your user has the required permissions to support the level of access required. AmazonAthenaFullAccess - Grants access to all actions and all resources

  5. Select Security credentials > Create access key

  6. Download .csv file - This file contains the key that will be entered into Zepl's Athena Data Source. DO NOT LOSE THIS file.