A simple lambda (nodejs) script to forward API POST calls to a private subnet
- API Gateway and AWS lambda
request
andrequest-debug
npm modules
- Create an AWS Lambda function
- Ensure the Lambda function is tied to a VPC and subnet a. this is required in order to communicate with the private subnet
- Download the
request
andrequest-debug
npm modules and save them to this directory a.npm install --prefix=[directory] aws-sdk
- zip the directory
zip -r [name].zip *
and upload it to Lambda - Create an Environment Variable call
ENDPOINT
and for the value enter the address to forward the HTTP requests in the private subnet
- Make sure the Lambda function is tied to an API Gateway (navigate to Triggers in Lambda) a. you may need to create a new API
- Create a Resource and then under actions click
create method
to create aPOST
methos - In the Method Execution menu, under Integration Request click
Use Lambda Proxy Integration
- Deploy the API and test it