Prerequisites
- A set of IAM credentials which allow access to AWS Athena
- The AWS region
- The S3 bucket on AWS to store query results
Setup
Manual
Add the following to a.env file in your Cube project:
Static Credentials
IAM Role Assumption
For enhanced security, you can configure Cube to assume an IAM role to access Athena:- If running in AWS (EC2, ECS, EKS with IRSA), the driver will use the instance’s IAM role or service account to assume the target role
- You can also provide
CUBEJS_AWS_KEYandCUBEJS_AWS_SECRETas master credentials for the role assumption
Cube Cloud
In some cases you’ll need to allow connections from your Cube Cloud deployment
IP address to your database. You can copy the IP address from either the
Database Setup step in deployment creation, or from Settings →
Configuration in your deployment.
OIDC workload identity
Instead of static credentials, Cube Cloud deployments can authenticate to Athena with OIDC workload identity: an IAM role in your account trusts Cube’s OIDC issuer, and the driver assumes it through the AWS SDK’s default credential chain — no access keys to provision or rotate.Environment Variables
1 Either provide
CUBEJS_AWS_KEY and CUBEJS_AWS_SECRET for static credentials, or use CUBEJS_AWS_ATHENA_ASSUME_ROLE_ARN for role-based authentication. When using role assumption without static credentials, the driver will use the AWS SDK’s default credential chain (IAM instance profile, EKS IRSA, or OIDC workload identity in Cube Cloud).
Pre-Aggregation Feature Support
count_distinct_approx
Measures of typecount_distinct_approx can
be used in pre-aggregations when using AWS Athena as a source database. To learn
more about AWS Athena’s support for approximate aggregate functions, click
here.
Pre-Aggregation Build Strategies
To learn more about pre-aggregation build strategies, head
here.
By default, AWS Athena uses a batching strategy to
build pre-aggregations.
Batching
No extra configuration is required to configure batching for AWS Athena.Export Bucket
AWS S3
For improved pre-aggregation performance with large datasets, enable export bucket functionality by configuring Cube with the following environment variables:Ensure the AWS credentials are correctly configured in IAM to allow reads and
writes to the export bucket in S3.