Add an API Gateway trigger to a AWS Lambda function to create a REST API

Tomasz Łakomy
InstructorTomasz Łakomy
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 4 years ago

Once the AWS Lambda function is created in AWS Cloud, we'd like to be able to call it outside of the AWS Console

In order to do that - we need to create a trigger.

In this lesson we're going to learn how to create an API Gateway trigger and attach it to a AWS Lambda function so the function will get triggered once an HTTP request is sent to this API.

Tomasz Łakomy: [0:00] We have a Lambda function that we would like to be able to execute outside of the AWS console. In order to do that, we need to add a trigger to this function. Click on Add trigger. Here, we can select what kind of trigger do we want to add to this function.

[0:13] I would like to be able to call this function via HTTP request, so I'm going to add an API Gateway. API Gateway allows us to create an API with only a couple of clicks.

[0:22] There are two templates available, so we can use either HTTP API or the REST API. HTTP API is rather new, so we're going to work with that because we want to be cutting-edge.

[0:32] By default, this is going to be open, so I will be able to call it from my local machine outside of AWS. Next, click on Add. We can see over here, that the trigger has been added. API Gateway is going to trigger myFunction.

[0:45] Down here, we can see my API. If I expand it, we can see that there is no Security currently, there's no Authorization, and basically, we have an open endpoint.

[0:53] If I click on that, I will execute my Lambda function and there will be a result over here, "Hello from Lambda!"

[1:00] If I were to go ahead and change this function to say, "Hello from Egghead Lambda!" and save it. Now, if I refresh over here, I'm going to get the result, "Hello from Egghead Lambda!"

egghead
egghead
~ just now

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today