I am currently learning how to expose my lambda function with API Gateway. I followed the instructions documented here and created an API that triggers my test lambda function. Here's the summary of what I did.
Ok, so I tested the solution above in API Gateway console. It's working fine and I just need to deploy that by creating a stage and I am done.
But then I noticed another way of exposing lambda with API Gateway. That is, by going to that lambda function and add an API Gateway trigger to it. Like the following:
It will ask to to enter the API name of the API that I will use. This API somehow relates to the one that I created under API Gateway console.
After creating the trigger, the test lambda function will now have a trigger that looks like this, and an https URL exposed under it.

Then after that, when I go to the API Gateway console I noticed that a new resource is added.

The resource name is the name of my test lambda function and the method is ANY and I don't quite understand the use of this.
By comparing the above with the resource I created earlier. The one above does not have the ARN address of the lambda function while this one has

So, my question is,
what is the difference between creating an API and adding an integration for it with lambda and adding a trigger from lambda with an existing API from API Gateway?
Can the https address exposed under lambda function(After adding trigger from API Gateway) be used directly?
If adding trigger to lambda will work as the same. Then do I still need to create a stage to deploy my api?
- what is the difference between creating an API and adding an integration for it with lambda and adding a trigger from lambda with an existing API from API Gateway?
Those are two different ways to create an API Gateway-Lambda integration. There is no difference if you configure them both the same way.
- Can the https address exposed under lambda function(After adding trigger from API Gateway) be used directly?
Yes, you can use it directly.
- If adding trigger to lambda will work as the same. Then do I still need to create a stage to deploy my api?
Yes. The URL comes from the stage, so you need at least one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With