Querying Sources Beyond S3 with Athena Federated Query
This lesson explains how Athena federated query reads data in databases, logs and other sources through Lambda-based connectors and joins it with lake data in one SQL statement, without first copying it.
Learning outcomes
After completing this lesson, you will be able to:
- Describe how data source connectors work.
- Deploy and configure a connector.
- Decide when federation is better than copying data.
How federated query works
Athena's engine reads data from Amazon S3 natively. To read other sources, it uses data source connectors, which run as AWS Lambda functions. When a query refers to a table in another source, Athena calls the connector, which reads the data from the source, applies any filters it can push down to the source, and returns rows to Athena in a common format. Athena then joins them with data from S3 or other connectors in the same query.
AWS provides connectors for many sources, including Amazon DynamoDB, Amazon RDS and Aurora with MySQL or PostgreSQL, Amazon Redshift, Amazon CloudWatch Logs, Amazon DocumentDB and Amazon OpenSearch Service. Connectors also exist for on-premises databases through JDBC and for software-as-a-service sources, and teams can write their own with the Athena Query Federation SDK.
The following diagram shows how the query reaches each source.

Deploying connectors
A connector must be deployed and configured before queries can use it. It is deployed from the Athena console or the AWS Serverless Application Repository, and it can be registered as an AWS Glue connection so that its tables appear in the catalogue. Because the connector is a Lambda function, it needs network access to its source: for a database in a VPC, the function is configured to run in that VPC with a security group that the database allows.
Two further pieces are required. Lambda responses have a size limit, so each connector needs an S3 spill bucket where it writes results that are too large to return directly. And the credentials for the source are stored in AWS Secrets Manager, from which the connector retrieves them, so no passwords appear in the configuration.
Deploying a connector
When to federate
Athena Federated Query uses Lambda-based connectors to query sources outside S3, such as DynamoDB, RDS or other databases, in the same SQL as lake tables. Each query reads the source live, through a Lambda function, so it suits occasional, ad hoc joins across systems and exploring data before deciding whether a pipeline is worth building. For heavy analytics that run regularly, or any query that would slow the source system, it is better to copy the data into S3 or Redshift, where it can be queried efficiently without touching production. The following table summarises the choice.
| Use federated query for | Instead, copy data to S3 or Redshift for |
|---|---|
| Occasional, ad hoc joins across systems | Heavy, recurring analytics |
| Exploring data before building a pipeline | Anything that would slow down or load the source system |
Federate or copy?
One query across three sources
An analyst needs to join customer records in DynamoDB, orders in Aurora MySQL and clickstream data in S3, once, for an investigation. The following table compares the two approaches.
| Approach | Effort | Suitable for |
|---|---|---|
| Build ETL pipelines to copy everything into S3 | Days | Regular, high-volume reporting |
| Athena federated query with DynamoDB and MySQL connectors | Hours | Occasional queries across sources |
Federated query is the right choice for an occasional investigation. If the same join became a daily report, copying the data into the lake (or using zero-ETL) would be faster and avoid putting query load on the operational databases.
Where do Athena federated query connectors run?
Show answer
As Lambda functions.
Exam Tips
Remember for the exam
- SQL over DynamoDB or CloudWatch Logs calls for Athena federated query.
- Federated query connectors run as Lambda functions.
- To join a database table with S3 data in one query, use a federated query.
- Connectors need network access to the source and an S3 spill bucket.
- For heavy, recurring analytics, land the data in S3 or Redshift rather than federating.