You can create one lambda to handle all endpoints but there are a few disadvantages. 1. The lambda needs all code for every endpoint. This means it takes longer to load on a cold start. 2. All logs for every endpoint end up in the same place. If you want to find the last logs from a certain endpoint you have to find it in between all the rest. One lambda per endpoint means one log group per endpoint. 3. You don't need to write any logic to read the event and decide which function to use. Less logic = less things to go wrong In my opinion one lambda per endpoint is the best way to go.
Great video! however, I think the easiest approach will be just node API in docker and host as function in cloud(AWS/Azure) reason is AWS services are using node. really is just node. code is more manageable after years. I wrote a workable serverless function in 2018 uses API/Lambda/DynamoDB, however, when I look at the code, I forget why was doing that way, funny thing is the code still working today.
You definitely can just run a node app in ec2. But then you have to think about operations things too. What VPC am I in, what security group am I using, will the server cope if I get 10 requests a second, what if the server crashes, what if someone tries to hack my server. The great thing with serverless is that AWS handles all of that for you. I think if you didn't write a node server (assuming express) for 4 years then looked back at the code you'd forget why you did things that way too. If you use them regularly you build patterns and another dev that is familiar with Lambda should be able to quickly understand what you've done.
Great video, I would like to ask you something off the video topic, can tou please recomend a resource or video to create an elasticsearch cluster for products management with dynamo stream. using Aws console or serverless framework but with security measures like a vpc for the cluster I appreciate any helpful comments
This is something that I worked on once a very long time ago. We did it with the serverless framework as doing something of this complexity in the console is going to be frustrating to manage. I think it was put it together from a combination of articles. One for the VPC, one for elasticsearch and then another to connect to Dynamo streams. I don't know if there will be any videos or tutorials on how to set up everything. Sorry I can't be of more use
Things get a bit more complex when you want to add an npm package. The easiest way is to lambda layer with it in. You put the npm package into a folder like this. nodejs/node_modules/express You then zip up the nodejs folder and upload it as a layer. Attach that layer to this lambda.
Great content Sam. I would like to understand GSI's and queryStringParameters in more detail using serverless framework or api gateway. I want to be able to query an api with multiple parameters Any plans to do something with that?
Great suggestion! queryStringParameters are pretty simple. API Gateway passes them straight through and are often used for things like "from" and "to" in date ranges or passing other parameters. It's what you do with them once they're in the Lambda that becomes useful. GSI are more complex. I have a video outlining what they are and how to use them. ua-cam.com/video/BNshfC0ZOqs/v-deo.html The really powerful thing is when you combine the two. You can enable a user to pass a query string parameter and then you query your GSI based on what parameter they sent you. I might add a video detailing an architecture that uses that.
@@khandoor7228 Here's the structure to add a GSI to a dynamo tables. It uses serverless.ts but the structure is the same github.com/SamWSoftware/interviewAPI/blob/master/serverless/dynamodb.ts
Absolute top quality content from this channel as always.
Your lesson saved my day. Thanks a lot.
@9:17 did you make a video with the DynameDB integration?? :D
ua-cam.com/video/pp-5u6LB9K8/v-deo.html
This was helpful!! I'm new to AWS. Is it ideal to create lambda function per endpoint when managing an API via API Gateway?
You can create one lambda to handle all endpoints but there are a few disadvantages.
1. The lambda needs all code for every endpoint. This means it takes longer to load on a cold start.
2. All logs for every endpoint end up in the same place. If you want to find the last logs from a certain endpoint you have to find it in between all the rest. One lambda per endpoint means one log group per endpoint.
3. You don't need to write any logic to read the event and decide which function to use. Less logic = less things to go wrong
In my opinion one lambda per endpoint is the best way to go.
Great Sam, nice to revisit this and refresh!
Glad you enjoyed it!
The console has changed so much that my original video (2nd ever video) was wrong.
Very well explained, would love to see the DynamoDB integration as well :)
That's a good idea. I can take the existing code and add dynamo reads and writes
@@CompleteCoding if you have complete please share us.
@@akillchetu4223 ua-cam.com/video/pp-5u6LB9K8/v-deo.html
ua-cam.com/video/pp-5u6LB9K8/v-deo.html
Great video! however, I think the easiest approach will be just node API in docker and host as function in cloud(AWS/Azure) reason is AWS services are using node. really is just node. code is more manageable after years. I wrote a workable serverless function in 2018 uses API/Lambda/DynamoDB, however, when I look at the code, I forget why was doing that way, funny thing is the code still working today.
You definitely can just run a node app in ec2. But then you have to think about operations things too.
What VPC am I in, what security group am I using, will the server cope if I get 10 requests a second, what if the server crashes, what if someone tries to hack my server.
The great thing with serverless is that AWS handles all of that for you.
I think if you didn't write a node server (assuming express) for 4 years then looked back at the code you'd forget why you did things that way too.
If you use them regularly you build patterns and another dev that is familiar with Lambda should be able to quickly understand what you've done.
Great video, I would like to ask you something off the video topic, can tou please recomend a resource or video to create an elasticsearch cluster for products management with dynamo stream.
using Aws console or serverless framework but with security measures like a vpc for the cluster
I appreciate any helpful comments
This is something that I worked on once a very long time ago. We did it with the serverless framework as doing something of this complexity in the console is going to be frustrating to manage.
I think it was put it together from a combination of articles. One for the VPC, one for elasticsearch and then another to connect to Dynamo streams. I don't know if there will be any videos or tutorials on how to set up everything.
Sorry I can't be of more use
Thank you so much for making these wonderful videos!
Glad they are so useful
Is this UI for Api Gateway new or old? Because this looks different than that i am able to see and looks a lot better
I didn't film it that long ago so I hope it's the new one. You should have the ability to update your UI.
Wow ...You explained it so well 👍👍👍👍 thank you so much ,one more question Sam can we add dependencies like express in the lambda ?
Things get a bit more complex when you want to add an npm package.
The easiest way is to lambda layer with it in. You put the npm package into a folder like this. nodejs/node_modules/express
You then zip up the nodejs folder and upload it as a layer. Attach that layer to this lambda.
@@CompleteCoding thank you for quick response ,by any chance have you covered the steps in any tutorials of yours ?
@@ankitaburman5406 i'd actually forgotten that I'd made this video
ua-cam.com/video/5a2LS7gNECk/v-deo.html
@@CompleteCoding you are amazing.. 👍👍👍thank you so much
Great content Sam. I would like to understand GSI's and queryStringParameters in more detail using serverless framework or api gateway. I want to be able to query an api with multiple parameters Any plans to do something with that?
Great suggestion!
queryStringParameters are pretty simple. API Gateway passes them straight through and are often used for things like "from" and "to" in date ranges or passing other parameters. It's what you do with them once they're in the Lambda that becomes useful.
GSI are more complex. I have a video outlining what they are and how to use them. ua-cam.com/video/BNshfC0ZOqs/v-deo.html
The really powerful thing is when you combine the two. You can enable a user to pass a query string parameter and then you query your GSI based on what parameter they sent you. I might add a video detailing an architecture that uses that.
@@CompleteCoding Thanks Sam the other tricky part is how it is set up in the serverless.yml file.
@@khandoor7228 Here's the structure to add a GSI to a dynamo tables. It uses serverless.ts but the structure is the same
github.com/SamWSoftware/interviewAPI/blob/master/serverless/dynamodb.ts
Great content but not that much views. Am a hipster or something ?
It was only released a few hours ago. I'm not (yet) one of those mega-youtubers who gets 1 million views in a day.