Call Athena with Step Functions - Amazon Step Functions
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Call Athena with Step Functions

Step Functions can control certain Amazon services directly from Amazon States Language (ASL). To learn more, see Working with other services and Pass parameters to a service API.

How the Optimized Athena integration is different than the Athena Amazon SDK integration

The Amazon Step Functions service integration with Amazon Athena enables you to use Step Functions to start and stop query execution, and get query results. Using Step Functions, you can run ad-hoc or scheduled data queries, and retrieve results targeting your S3 data lakes. Athena is serverless, so there is no infrastructure to set up or manage, and you pay only for the queries you run.

To integrate Amazon Step Functions with Amazon Athena, you use the provided Athena service integration APIs.

The service integration APIs are the same as the corresponding Athena APIs. Not all APIs support all integration patterns, as shown in the following table.

API Request Response Run a Job (.sync)

Supported Amazon Athena APIs:


There is a quota for the maximum input or result data size for a task in Step Functions. This restricts you to 256 KB of data as a UTF-8 encoded string when you send to, or receive data from, another service. See Quotas related to state machine executions.

The following includes a Task state that starts an Athena query.

"Start an Athena query": { "Type": "Task", "Resource": "arn:aws:states:::athena:startQueryExecution.sync", "Parameters": { "QueryString": "SELECT * FROM \"myDatabase\".\"myTable\" limit 1", "WorkGroup": "primary", "ResultConfiguration": { "OutputLocation": "s3://athenaQueryResult" } }, "Next": "Get results of the query" }

For information about how to configure IAM permissions when using Step Functions with other Amazon services, see IAM Policies for integrated services.