Access AWS Athena from lambda function in a VPC

0

Hi,

I have a lambda function written in Python3.7 which will submit SQL to Athena using the boto3 library. If the lambda function is not in VPC, it works fine. But, if we attach the lambda function to a VPC, it will time out while submitting a query to Athena. We have a similar problem before with AWS system manager, which was solved by creating VPC endpoints. But VPC endpoints are not available for Athena. What should I do? Any help will be appreciated!

cli
asked 5 years ago945 views
2 Answers
0

The request to the athena api needs to route over the internet. You'll need a nat instance or nat gateway in your vpc to provide that route for the lambda. https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat.html

Ellison
answered 5 years ago
0

I see. Thank you for your reply, Ellison!
If anyone runs into a similar situation, this simple tutorial shows how to create a NAT gateway: https://gist.github.com/reggi/dc5f2620b7b4f515e68e46255ac042a7
(The NAT gateway document on AWS is long and complicated for me.)

cli
answered 5 years ago
profile picture
EXPERT
reviewed 5 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions