> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/integrations/catalog/aws-athena.md).

# AWS Athena

Integration with Amazon Athena for running SQL queries on data stored in Amazon S3. Execute queries, retrieve results, and explore table metadata in your data lake.

### Connectors

Choose the connector that matches your authentication method. The options below use the names shown in StackAI.

| Connector  | Authentication |
| ---------- | -------------- |
| AWS Athena | Credentials    |

#### AWS Athena

Connect to Amazon Athena using AWS credentials to run SQL queries on data in S3

**Set up in AWS Athena**

1. In the AWS IAM console, create (or choose) a user with programmatic access and permissions for Athena, the underlying S3 locations, and AWS Glue Data Catalog (for example attach a policy such as AmazonAthenaFullAccess plus S3 read access).
2. Create an access key for that user and copy the **Access Key ID** and **Secret Access Key** (the secret is shown only once).

**Set up in StackAI**

1. Open **Settings → Connections**, add a connection, and select **AWS Athena**.
2. Enter the credentials and connection details in the fields below.
3. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

**Connection fields**

| StackAI field                | Required                 | What to enter                                                                                                                                                                                                                                                                                                                                                                  |
| ---------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| AWS Region                   | Yes                      | AWS region where your Athena resources are located (e.g., us-east-1). [Provider instructions](https://docs.aws.amazon.com/general/latest/gr/athena.html).                                                                                                                                                                                                                      |
| AWS Access Key ID            | Yes                      | AWS Access Key for an IAM user/role scoped to read-only Athena access. Grant only: athena:StartQueryExecution/Get\*, glue:Get\* on the target catalog, and s3:GetObject/ListBucket on the output location. Do NOT grant athena:CreateDataCatalog or broad S3 write. [Provider instructions](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html). |
| AWS Secret Access Key        | Yes                      | AWS Secret paired with the Access Key ID above. Must belong to a read-only Athena IAM principal. [Provider instructions](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html).                                                                                                                                                                    |
| AWS Session Token (Optional) | Optional / as applicable | AWS Session Token for temporary credentials (used with STS or IAM roles). [Provider instructions](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html).                                                                                                                                                                                                  |
| Data Catalog (Optional)      | Optional / as applicable | The name of the data catalog to use. Defaults to 'AwsDataCatalog' if not specified. [Provider instructions](https://docs.aws.amazon.com/athena/latest/ug/understanding-tables-databases-and-the-data-catalog.html).                                                                                                                                                            |
| Database Name (Optional)     | Optional / as applicable | Default database for queries. Can be overridden per-action. Leave empty if creating a new database. [Provider instructions](https://docs.aws.amazon.com/athena/latest/ug/understanding-tables-databases-and-the-data-catalog.html).                                                                                                                                            |
| Output Location              | Yes                      | S3 location for query results (e.g., s3://your-bucket/athena-results/). [Provider instructions](https://docs.aws.amazon.com/athena/latest/ug/querying.html).                                                                                                                                                                                                                   |

**Provider documentation:** [Setup reference](https://docs.aws.amazon.com/athena/latest/ug/setting-up.html).

#### Verify the connection

Check that the connection is healthy. Then run a read operation against a resource the connected account can access. A successful connection check confirms authentication; it does not guarantee permission for every action.

If access is denied, check the credential or OAuth permissions, the selected account or environment, and access to the specific resource. Update expired credentials or reconnect after permissions change.

### Use an action

1. Add the required **AWS Athena** action to the workflow.
2. Select a connection when the action requests one.
3. Complete the required fields. Use the reference picker when a value comes from another workflow step.
4. Run the workflow and inspect the action’s output. Check the result before using it in a later step.

### Actions

#### Start Query Execution

Start executing a SQL query in Amazon Athena and get the query execution ID

**Inputs**

| Field        | Type     | Required | Description                                         |
| ------------ | -------- | -------- | --------------------------------------------------- |
| Query String | textarea | Yes      | The SQL query to execute.                           |
| Database     | string   | No       | The database to use for this query (optional).      |
| Data Catalog | string   | No       | The data catalog to use for this query (optional).  |
| Workgroup    | string   | No       | The workgroup in which the query is run (optional). |

**Outputs**

| Field              | Type   | Description                                    |
| ------------------ | ------ | ---------------------------------------------- |
| Query Execution ID | string | The unique identifier for the query execution. |

#### Get Query Execution

Get the status and metadata for a query execution in Amazon Athena

**Inputs**

| Field              | Type   | Required | Description                                       |
| ------------------ | ------ | -------- | ------------------------------------------------- |
| Query Execution ID | string | Yes      | The unique ID of the query execution to retrieve. |

**Outputs**

| Field                  | Type   | Description                                    |
| ---------------------- | ------ | ---------------------------------------------- |
| Query Execution ID     | string | The unique identifier for the query execution. |
| Query String           | string | The SQL query string that was executed.        |
| Status                 | object | The status of the query execution.             |
| Statistics             | object | Statistics about the query execution.          |
| Result Output Location | string | S3 location where query results are stored.    |

#### Get Query Results

Get the results of a completed query execution in Amazon Athena

**Inputs**

| Field              | Type    | Required | Description                                                    |
| ------------------ | ------- | -------- | -------------------------------------------------------------- |
| Query Execution ID | string  | Yes      | The unique ID of the query execution to retrieve results from. |
| Max Results        | integer | No       | Maximum number of results to return (1-1000).                  |
| Next Token         | string  | No       | Token for pagination to get the next page of results.          |

**Outputs**

| Field      | Type   | Description                                                   |
| ---------- | ------ | ------------------------------------------------------------- |
| Columns    | array  | Metadata about the columns in the result set.                 |
| Rows       | array  | The rows of query results.                                    |
| Next Token | string | Token for pagination. If present, more results are available. |

#### Get Table Metadata

Get detailed metadata about a table in Amazon Athena including columns, types, and properties

**Inputs**

| Field        | Type   | Required | Description                                   |
| ------------ | ------ | -------- | --------------------------------------------- |
| Table Name   | string | Yes      | The name of the table to get metadata for.    |
| Database     | string | No       | The database containing the table (optional). |
| Data Catalog | string | No       | The data catalog to use (optional).           |

**Outputs**

| Field            | Type   | Description                                                                   |
| ---------------- | ------ | ----------------------------------------------------------------------------- |
| Table Name       | string | The name of the table.                                                        |
| Columns          | array  | List of columns in the table with their types.                                |
| Table Type       | string | The type of the table (e.g., EXTERNAL\_TABLE, MANAGED\_TABLE, VIRTUAL\_VIEW). |
| Create Time      | string | The time when the table was created.                                          |
| Last Access Time | string | The last time the table was accessed.                                         |
| Parameters       | object | Additional table parameters and properties.                                   |

#### List Table Metadata

List all tables in the database with their metadata in Amazon Athena

**Inputs**

| Field        | Type    | Required | Description                                           |
| ------------ | ------- | -------- | ----------------------------------------------------- |
| Expression   | string  | No       | A regex filter pattern for table names (optional).    |
| Max Results  | integer | No       | Maximum number of tables to return (1-50).            |
| Next Token   | string  | No       | Token for pagination to get the next page of results. |
| Database     | string  | No       | The database to list tables from (optional).          |
| Data Catalog | string  | No       | The data catalog to use (optional).                   |

**Outputs**

| Field      | Type   | Description                                                   |
| ---------- | ------ | ------------------------------------------------------------- |
| Tables     | array  | List of table metadata summaries.                             |
| Next Token | string | Token for pagination. If present, more results are available. |

### Important behavior

Actions that create, update, send, or delete data can change the connected service. Review their inputs before running them. A retry can repeat an operation; consider this when configuring retries for actions that change data.

The catalog lists the fields and capabilities available in the supplied provider definition. Availability can also depend on your deployment and organization’s Feature Access settings.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/integrations/catalog/aws-athena.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
