Querying AWS Athena using a Lambda Function

2022.04.30

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

Athena

An AWS service that enables data analysts to perform interactive queries in the web-based cloud storage service, S3. It is usually used with large-scale data sets. It enables users to analyze data in Amazon S3 using SQL. It is mostly for quick, ad hoc, and complex analysis. A serverless service where underlying compute infrastructure need not be handled for the users.

AWS Lambda

A serverless compute service which runs code as a reply to events and automatically takes care of the bottom resources. It runs code on high availability compute infrastructure and performs all the administration of the compute resources. A few examples are HTTP requests vis Amazon API Gateway, changes to objects in S3, and many others.

Follow the below article to connect with s3 and how to query S3 files using Athena

Demo

First creating an execution role that will be used in the lambda function creating a lambda function Now increase the timeout so that lambda gets enough time to query Now move into the code section as shown below and make changes to the code Give the respective query you want to query, database name and output location i.e S3 bucket as specified in the above Athena article Now clicking deploy and testing the code