- Make sure you have your index.js file in the root of your projects directory. If this isn't here the Lambda function will throw an error.
- Make sure you don't use the base route in your express server. HTTP requests to this base route will not be sent to our proxy Lambda.
http://supercoolapigatewayurl.com/stageName
http://supercoolapigatewayurl.com/stageName/todos
- First create your lambda function. You can upload this code by selecting the content of directory and compressing it. Lambda allows you to take this zip file and upload it.
-
Now you can create your API Gateway. I used the Rest API for this but I'm sure HTTP API would work as well.
-
You need to add a resource on your API Gateway on the root path. Be sure to check the boxes for configure as proxy resource and enable API Gateway CORS. Then you need to link this resource to the lambda function that we created earlier.
- Now that we finished creating all of our API Gateway changes we need to go and deploy the API so we can test it.