Call Athena with Step Functions
Step Functions can control certain AWS services directly from the Amazon States Language. For more information about working with AWS Step Functions and its integrations, see the following:
-
The Run a Job (.sync) integration pattern is supported.
-
There are no optimizations for the Request Response integration pattern.
-
The Wait for a Callback with the Task Token integration pattern is not supported.
The AWS 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 AWS 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) |
---|---|---|
StartQueryExecution |
✓ | ✓ |
StopQueryExecution |
✓ | |
GetQueryExecution |
✓ | |
GetQueryResults |
✓ |
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 262,144 bytes 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.
-
-
Supported parameters:
-
-
Supported parameters:
-
-
Supported parameters:
-
-
Supported parameters:
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 on how to configure IAM when using Step Functions with other AWS services, see IAM Policies for integrated services.