Making a call to External API from AWS LAMBDA resides within VPC (Python)

Naveenkumar Murugan
8 min readSep 3, 2023

why I am writing this blog in first place

While numerous resources guide you through setting up AWS Lambda as an API and consuming it, there’s a scarcity of comprehensive documentation addressing the intricacies of making an external API call from a Lambda function residing within a Virtual Private Cloud (VPC).

what you’ll build

We are going to create a simple LAMBDA function which makes an external API call based of requests present in the input s3 file and store the responses back to s3, plus the required AWS environment.

Technical Architecture

  1. when the file is placed in S3, It triggers LAMBDA.
  2. LAMBDA sits in Private subnet going to reach out to private subnet’s route table.
  3. Then the router forwards request to request NAT gateway in Public subnet.
  4. Then NAT gateway forwards the request to Internet gateway as we defined the public subnet’s route table to forward the request (0.0.0.0/0) (Anything that doesn’t fall under…

--

--