> For the complete documentation index, see [llms.txt](https://docs.telm.ai/telmai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.telm.ai/telmai/connect-to-data/data-connections/aws-athena.md).

# Athena

Connect Telmai to Athena.

Telmai reads Athena tables with an IAM user's access key and writes query results to an S3 staging directory.

## Before you connect

1. Choose an S3 location for Athena query results, for example `s3://your-results-bucket/athena-results/`.
2. Create an IAM user for Telmai and an access key for it.
3. Attach this policy to the user. Replace `your-results-bucket` with the bucket for query results and `your-data-bucket` with the bucket that holds the table data.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Athena",
      "Effect": "Allow",
      "Action": [
        "athena:StartQueryExecution",
        "athena:StopQueryExecution",
        "athena:GetQueryExecution",
        "athena:GetQueryResults",
        "athena:GetWorkGroup",
        "athena:CreatePreparedStatement",
        "athena:UpdatePreparedStatement",
        "athena:GetPreparedStatement",
        "athena:DeletePreparedStatement"
      ],
      "Resource": "*"
    },
    {
      "Sid": "S3ResultsAndData",
      "Effect": "Allow",
      "Action": [
        "s3:GetBucketLocation",
        "s3:ListBucket",
        "s3:GetObject",
        "s3:PutObject",
        "s3:ListMultipartUploadParts",
        "s3:AbortMultipartUpload"
      ],
      "Resource": [
        "arn:aws:s3:::your-results-bucket",
        "arn:aws:s3:::your-results-bucket/*",
        "arn:aws:s3:::your-data-bucket",
        "arn:aws:s3:::your-data-bucket/*"
      ]
    },
    {
      "Sid": "Glue",
      "Effect": "Allow",
      "Action": [
        "glue:GetDatabase",
        "glue:GetDatabases",
        "glue:CreateDatabase",
        "glue:GetTable",
        "glue:GetTables",
        "glue:CreateTable"
      ],
      "Resource": "*"
    }
  ]
}
```

## Connection fields

On the **Connections** page, click **Add connection** and choose **Athena**. See [Add a connection](https://docs.telm.ai/telmai/connect-to-data.md#add-a-connection) for the full flow.

| Field                    | Description                                                                                |
| ------------------------ | ------------------------------------------------------------------------------------------ |
| **Database or Schema**   | The Athena database whose tables Telmai lists, for example `sales`.                        |
| **AWS Region**           | The region of your Athena workgroup, for example `us-east-1`.                              |
| **S3 Staging Directory** | The S3 location for query results, for example `s3://your-results-bucket/athena-results/`. |
| **AWS Access Key**       | The IAM user's access key ID.                                                              |
| **AWS Secret Key**       | The IAM user's secret access key.                                                          |

## Asset fields

Click **Add assets** on the connection. See [Add assets](https://docs.telm.ai/telmai/connect-to-data.md#list-of-connectors-enabled-by-default).

The **Configure** step has no Athena-specific fields. Choose **Existing table** or **Custom query**; see [Connection Modes](https://docs.telm.ai/telmai/connect-to-data/connection-modes.md).
