Search code examples
amazon-web-servicesaws-lambdaamazon-athena

AWS Athena - Connect from Lambda


connecting/Running query in an aws athena via lambda function is working fine, but when i connect using lambda with vpc, it gives timeout error. please suggest a solution to resolve this


Solution

  • Since your function is "in" a VPC, there are two options to enable access to Athena:

    • Place your function in private subnet (public will not work), and setup NAT gateway in a public subnet with correct route tables. This way, your function will connect to Athena using NAT and subsequently, the internet.
    • Create a VPC interface endpoint for Athena in your VPC. This does not require internet access, nor NAT. Subsequently you can privately connect to Athena without leaving AWS.