Amazon Web Services has a generous free tier for Lambda which involves 1 million free invocations.
With the release of HTTP API for API Gateway, you can use Lambda as a proxy for any service.
The source code is available here -> AWS Lambda Proxy using Nodejs
Why would you use Lambda as a Proxy?
- Security - We don't want to expose the API end-point directly to the internet
- Resilience - If the external service goes down, we can use lambda to re-direct to an another instance of the API.
How to use AWS Lambda as a Proxy?
AWS Lambda Proxy Architecture |
- You start by creating a new lambda function (we will call it the proxyJS). This will be the end-point where user submits the form.
API Gateway Trigger for Proxy Lambda (Click to enlarge) - Now we can call any external end-point. But in order to de-couple our architecture, we will use an AWS SNS topic that will get data from the Proxy lambda.
- This topic will be subscribed by another Lambda function called externalJS that will call an external service with the topic data
- In the above architecture, we are calling an external Google Cloud HTTP function using Nodejs using the above lambda
SNS Trigger for AWS Lambda |
0 comments:
Post a Comment
What do you think?.