Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between creating a method that accesses a lambda function in API Gateway and adding an API Gateway trigger to a lambda function

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.

  1. First I created a test lambda function with hello world template BUT WITH NO TRIGGER ADDED to it.
  2. Then I go to the API Gateway console, added a resource with GET method specifying the integration type to Lambda function. I entered my test lambda function name there.

enter image description here

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:

enter image description here

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.

enter image description here

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

enter image description here

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

enter image description here

So, my question is,

  1. 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?

  2. Can the https address exposed under lambda function(After adding trigger from API Gateway) be used directly?

  3. If adding trigger to lambda will work as the same. Then do I still need to create a stage to deploy my api?

like image 657
JLT Avatar asked May 01 '26 02:05

JLT


1 Answers

  1. 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.

  1. Can the https address exposed under lambda function(After adding trigger from API Gateway) be used directly?

Yes, you can use it directly.

  1. 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.

like image 81
Noel Llevares Avatar answered May 05 '26 09:05

Noel Llevares



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!