Zepl
Search…
Amazon Athena

Create an Amazon Athena Datasource

  1. 1.
    Navigate to: Resources > Data Sources
  2. 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
1
%python
2
​
3
# Connect to Athena. Returns: botocore.client.Athena object
4
client = z.getDatasource("zepl_docs_athena")
5
​
6
# Set parameter values for query execution
7
params = {
8
'region': 'us-west-1',
9
'database': 'default',
10
'bucket': 'shainsky-athena-demo',
11
'path': 'athena_queries',
12
'query': ( """ SELECT os, COUNT(*) count
13
FROM default.cloudfront_logs
14
WHERE date BETWEEN date '2014-07-05' AND date '2014-08-05'
15
GROUP BY os
16
""")
17
}
18
​
19
# Execute query in athena and return result files to the S3 bucket specificed at OutputLocation path
20
response = client.start_query_execution(
21
QueryString=params['query'],
22
QueryExecutionContext={
23
'Database': params['database']
24
},
25
ResultConfiguration={
26
'OutputLocation': 's3://' + params['bucket'] + '/' + params['path']
27
}
28
)
Copied!
Use z.getDatasource() to return Botocore Athena client object: botocore.client.Athena​

Configure Authentication

  1. 1.
    Login to AWS
  2. 2.
    Navigate to IAM > Users
  3. 3.
    Select your user name
  4. 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. 5.
    Select Security credentials > Create access key
  6. 6.
    Download .csv file - This file contains the key that will be entered into Zepl's Athena Data Source. DO NOT LOSE THIS file.
Last modified 1yr ago