Blog cover

AWS Lambda X API Gateway

Host any piece of code in minutes for cheap with AWS Lambda

 

AWS Lambda

AWS lambda functions are powerful way to host any simple functionality you want to expose if

  • you know the function will not be accessed often
  • You dont want to deployment on EC2 or EKS because it’s such a simple piece of code that it’s not worth the headache

For these reason you should choose to host on Lambda as an instance will be created by AWS only when the function is actually called from the client, this keeps your costs minimal, and can get you started immediately

 

API gateway

API gateway is a service provided by AWS which allows you to expose various resources in the AWS ecosystem as HTTP/ REST api’s. These can be public or Private (on internal network)

For us it is one of the best ways to expose our Lambda functions to the rest of the world.

notion image
 

These are the steps we need to follow to setup the AWS lambda and API gateway

  1. Create a simple Lambda function
notion image
notion image
 
  1. Add an API gateway trigger to it
notion image
notion image
  1. Create a REST api endpoint to it , (with CORS enabled)
notion image
  1. Deploy the endpoint by creating a new stage. default