AWS Made Simple: Trigger a lambda function via API Gateway
May 27, 2020
Once we create an AWS Lambda function we probably want to be able to call it (otherwise, why bother creating a function at all?).
With AWS Lambda you can create a serverless REST API in no time!
Let's start with a brand new lambda function, which as you can see - by default has no triggers.
Consider clicking on the
Add trigger button, who knows what will happen!
As we can see, there's a surprising number of things that can trigger a lambda function. Maybe one day we'll be able to trigger lambda by just thinking about it, who knows.
In any case - let's select
API Gateway from the list and let's create an API from scratch:
We can choose between
HTTP API and
HTTP API is still in beta but it's cutting edge and we want to one of the cool kids - let's go with that.
Leave everything as default and click on
(Quick note: by default the newly created API will be open, so we'll be able to access it from the Internet. Not a huge deal now, but we might consider being more careful once our lambda functions deal with sensitive data etc.)
Lo and behold! We have created an API Gateway and connected it to our Lambda function
(Consider adding this skill to your LinkedIn, more than happy to endorse you)
Our brand new API endpoint will look more or less like this:
And once we paste it into our browser, something magical will happen - a
"Hello from Lambda!" string will appear on our screen 🎉
This is fantastic - now we're able to create our own APIs in no time, and the whole process takes minutes (if not seconds!)
Óne more thing!
If you don't feel like reading and prefer to watch a bunch of quick (less than 3 minutes) videos - this blog series is based on a 💰free 💰egghead.io video collection I've published recently, check it out here: Learn AWS Lambda from scratch.
AWS Cloud Development Kit allows you to build the entire stack (frontend, serverless backend, AWS infrastructure) using a single programming language - TypeScript!