Creating an API with Serverless - API Gateway and AWS Lambda

  Рет қаралды 30,221

Complete Coding - Master AWS Serverless

Complete Coding - Master AWS Serverless

4 жыл бұрын

Full Serverless playlist here • The Serverless Framewo...
In this lesson we'll learn how we can build a Lambda function that works with API Gateway to create an API.
I this video you'll learn:
- How to set up a Lambda in Serverless
- What response you need to return to work with API Gateway
- How to deploy the Lambda and API Gateway using Serverless
- How to test GET requests in the browser
Starting Code: github.com/SamWSoftware/Serve...
Final Code: github.com/SamWSoftware/Serve...

Пікірлер: 73
@johnbarker5686
@johnbarker5686 3 жыл бұрын
Great tutorial- thank you so much! Updating this to latest: provider: ... httpApi: cors: true functions: getUser: handler: lambdas/getUser.handler events: - httpApi: method: GET path: /get-user/{ID}
@Unnonamus
@Unnonamus 3 жыл бұрын
You saved me from going off the rails, thank you! This should probably be stickied at the top.
@CompleteCoding
@CompleteCoding 3 жыл бұрын
Yes, there's a v2 of serverless now which has made the inclusion of httpApi. You should still be able to use "http" though
@CompleteCoding
@CompleteCoding 3 жыл бұрын
@@rayandwayne3275 Glad that you found it useful
@yisellrodriguezleiva7692
@yisellrodriguezleiva7692 2 жыл бұрын
Great simple and clear.. that is what I was looking for, tutorials that go straight to the point .. thank you
@CompleteCoding
@CompleteCoding 2 жыл бұрын
Glad it was useful :)
@stefan1632
@stefan1632 3 жыл бұрын
Great training videos series! I'm currently studying for developer associate and this is helping cement the concepts.
@CompleteCoding
@CompleteCoding 3 жыл бұрын
Glad it was helpful!
@AmruAshik
@AmruAshik 3 жыл бұрын
the bestttt video series ever for js developers!! thank you!
@CompleteCoding
@CompleteCoding 3 жыл бұрын
Wow, thanks!
@WezPyke
@WezPyke 4 жыл бұрын
Thanks Sam for the great video.
@CompleteCoding
@CompleteCoding 4 жыл бұрын
My pleasure!
@user-nd1ui7fl3x
@user-nd1ui7fl3x 2 жыл бұрын
Great tutorial - thank you so much
@muzammalabdulghafoor6418
@muzammalabdulghafoor6418 3 жыл бұрын
Wow man! Thats really helpful, I really appreciate your effort what you're putting...Thanks a lot!
@CompleteCoding
@CompleteCoding 3 жыл бұрын
Glad it was helpful!
@MarcelaoVMS
@MarcelaoVMS 3 жыл бұрын
Thank you very much for this amazing video!
@CompleteCoding
@CompleteCoding 3 жыл бұрын
You're very welcome!
@neosarchizo
@neosarchizo 4 жыл бұрын
Thx for good video again!
@CompleteCoding
@CompleteCoding 4 жыл бұрын
Thanks for watching!
@asekawarnakulasooriya7909
@asekawarnakulasooriya7909 4 жыл бұрын
great video!
@CompleteCoding
@CompleteCoding 4 жыл бұрын
Glad you enjoyed it
@victorps5366
@victorps5366 3 жыл бұрын
All... Excelent!!
@CompleteCoding
@CompleteCoding 3 жыл бұрын
Thank you! Cheers!
@letsgodevs
@letsgodevs 3 жыл бұрын
Thank you thank you thank you very much sir for this video
@CompleteCoding
@CompleteCoding 3 жыл бұрын
Thanks for commenting on all my videos :) It really helps share them to more people
@devprakash5320
@devprakash5320 2 жыл бұрын
Great video
@CompleteCoding
@CompleteCoding 2 жыл бұрын
Glad you enjoyed it
@muzammalabdulghafoor6418
@muzammalabdulghafoor6418 3 жыл бұрын
Keep it up!
@CompleteCoding
@CompleteCoding 3 жыл бұрын
That's the plan!
@iotforlife6691
@iotforlife6691 3 жыл бұрын
Starting to watch
@CompleteCoding
@CompleteCoding 3 жыл бұрын
Hope you enjoy it
@user-nm5kd8pm8z
@user-nm5kd8pm8z Жыл бұрын
Thank you for the video. It didn't show me a link to check this function. Where can I find my link?
@shadmanmartinpiyal4057
@shadmanmartinpiyal4057 3 жыл бұрын
These are amazing tutorials. You should consider opening a course on Udemy. You are way better than those AWS Udemy instructors.
@CompleteCoding
@CompleteCoding 3 жыл бұрын
I've done one small course on Udemy but I'm considering doing a KZfaq SaaS build series and then adding extra details and putting it on Udemy too.
@josejaimes4965
@josejaimes4965 4 жыл бұрын
Hi Sam, I noticed I had to comment all the lines inside DemoBucketUpload when I tried to run "sls deploy" command because of this error : An error occurred: NewResource - mynewbucketwithserveless-1927 already exists. After that, it works! ( You can see this section in this video at 10:36 )
@CompleteCoding
@CompleteCoding 4 жыл бұрын
That just means that someone has already claimed that bucket name. It might even have been you in a previous project. You could have also just altered the bucket name to achieve the same result
@adisilagy
@adisilagy 2 жыл бұрын
Awesome video! I was wonder, do you prefer working with js or typescript?
@CompleteCoding
@CompleteCoding 2 жыл бұрын
I definitely prefer typescript now. It took a bit to get used to but makes everything more consistent now. I can define what I expect to receive from an api request and then everything will autocomplete. It warns me when I pass an incorrect parameter or have a typo.
@fmolinari2012Utube
@fmolinari2012Utube 3 жыл бұрын
Hi, Excellent tutorial. I need help to identify the problem why I'm getting a 502 in the browser when I try to run the API. serverless deploy worked fine. Thank you.
@CompleteCoding
@CompleteCoding 3 жыл бұрын
Glad that it was helpful
@eespxtra1059
@eespxtra1059 4 жыл бұрын
Thank you so much for this guide. I did everything the way you teach but I have a problem because when I go into endpoint I have an error {"message": "Internal server error"} - How to fix this ??
@CompleteCoding
@CompleteCoding 4 жыл бұрын
This means there's a bug in the code. You can run sls logs -f ${yourFunctionName} to get the latest logs. You should then be able to see what the error is from them. The other option is to go into the console, find your lambda, select "monitoring" and then "View logs in CloudWatch" which will show you the logs in the console.
@alexgochenour8740
@alexgochenour8740 4 жыл бұрын
This is fantastic. But is the a specific reason why you chose to use Require.JS rather than ES6 modules? Anyway, thanks and keep 'em coming.
@CompleteCoding
@CompleteCoding 4 жыл бұрын
The first few videos in this series were done before the use of webpack. If you try and use ES6 and import without webpack then your lambdas will always error. I probably should have updated them all in the webpack video.
@sungjun94
@sungjun94 2 жыл бұрын
hello, this is a great tutorial by the way!!! I have two quick questions which I wish you could demonstrate in the video as well, was 1. How do you invoke the message, {message: "missing the ID from the path"} and 2. how do you access 'event' which you console logged from the editor? Thanks!!!
@CompleteCoding
@CompleteCoding 2 жыл бұрын
You can't trigger that message via the api. If you don't pass an id then api gateway won't pass the message to the lambda. Its likely to happen if you point the wrong endpoint to the wrong lambda. To see the logs, open the lambda in the console. Then click the 'monitoring' tab and 'view in cloudwatch'. You can see everything that gets console.log out in your code.
@sungjun94
@sungjun94 2 жыл бұрын
@@CompleteCoding Thank you!!! Best tutorial
@AhmedBesbes
@AhmedBesbes 4 жыл бұрын
Excellent video ! Could you make video on how building a deployment package using serverless and python?
@CompleteCoding
@CompleteCoding 4 жыл бұрын
I've not done much with Python in production but the process is the same. create a new project with "sls create --template aws-python --path myService" setup your AWS credentials if you haven't already modify the python endpoint or create more of your own update the serverless.yml file for your changes or new endpoints sls deploy
@AhmedBesbes
@AhmedBesbes 4 жыл бұрын
@@CompleteCoding Thanks ! I'm sorry I was not clear enough. Sometimes, with python I have very large dependencies (with c bindings), given that the max size is about 250MB, i was wondering if there was a way to circumvent this with serverless.
@CompleteCoding
@CompleteCoding 4 жыл бұрын
You can use Lambda Layers or EFS to get around this. Lambda layers would be easier but still has file limits. EFS would allow much larger dependencies. I've got a video on Layers (not with serverless though) kzfaq.info/get/bejne/a8dif7ZozLSpc58.html I've not done a video on adding EFS to lambda yet
@AhmedBesbes
@AhmedBesbes 4 жыл бұрын
@@CompleteCoding thank you mate
@andresm9051
@andresm9051 2 жыл бұрын
Great video, do you know an example of applying idempotency to the api to avoid repeated requests?
@CompleteCoding
@CompleteCoding 2 жыл бұрын
You could write a 'lock' to a dynamo table on the first request so later requests know not to process. Idempotency is usually only be required for update requests where the data is relative to the current value. Eg. Increment likes by one. I try to avoid this kind of request where ever possible, instead providing the actual values. I avoid it because there are almost always race conditions or other effects that can cause issues.
@andresm9051
@andresm9051 2 жыл бұрын
@@CompleteCoding ok thanks a lot for explaining
@rohith_sivapuram4804
@rohith_sivapuram4804 3 жыл бұрын
Heloo Wt was extension needed for serverless. Yml file?
@CompleteCoding
@CompleteCoding 3 жыл бұрын
You don't need any vs code extensions to use serverless.yml files
@sedatcanyalcn892
@sedatcanyalcn892 3 жыл бұрын
I believe the response object in API Gateway has changed; status -> statusCode now we have a property isBase64Encoded that we can set to false
@CompleteCoding
@CompleteCoding 3 жыл бұрын
Yes, it should be statusCode now :) Nice spot
@HariHaran-nf9ky
@HariHaran-nf9ky 3 жыл бұрын
Sir I did upto deployment....after i'm open the url and it show "Missing Authentication Token"
@CompleteCoding
@CompleteCoding 3 жыл бұрын
That means that either you're probably on the wrong url.
@RakeshBitling
@RakeshBitling 3 жыл бұрын
Hello sir how to perform in vscode all those cli commands
@CompleteCoding
@CompleteCoding 3 жыл бұрын
You can open the terminal in VS Code using "View > Terminal" or there are shortcuts. This then works as any other terminal would do.
@marwanehamdani2450
@marwanehamdani2450 2 жыл бұрын
Whenever I deploy and open the url I get an internal server error how do we fix it ?
@CompleteCoding
@CompleteCoding 2 жыл бұрын
First look at the cloudwatch logs. Does that indicate why the lambda is erroring. You can then wrap your code in a try-catch block and log out the error. Once you know the error that is causing it, you can fix it.
@rohith_sivapuram4804
@rohith_sivapuram4804 3 жыл бұрын
Getting to enter path(0), path(1) after entering sls deploy... Wt to do?
@CompleteCoding
@CompleteCoding 3 жыл бұрын
I've not seen that error before. Have you entered the path for the endpoints in the serverless.yml file?
@753abhishek
@753abhishek 3 жыл бұрын
use
@arrywil
@arrywil Жыл бұрын
I think this is due to a conflict with a PowerShell select command. If you use the following it should temporarily remove the alias for the session: Remove-Item alias:sls After this sls deploy should work as you would expect.
@murvinlai
@murvinlai 3 жыл бұрын
Is your demo source code on Github?
@CompleteCoding
@CompleteCoding 3 жыл бұрын
Just added it to the description but here they are for you. starting code: github.com/SamWSoftware/ServerlessKZfaqSeries/tree/lesson2-S3 final code: github.com/SamWSoftware/ServerlessKZfaqSeries/tree/lesson3-api
Adding Serverless Webpack to your Project - fix Lambda Upload Limits
10:23
Complete Coding - Master AWS Serverless
Рет қаралды 16 М.
Securing Your Serverless API With API Keys
14:21
Complete Coding - Master AWS Serverless
Рет қаралды 10 М.
Can A Seed Grow In Your Nose? 🤔
00:33
Zack D. Films
Рет қаралды 30 МЛН
Викторина от МАМЫ 🆘 | WICSUR #shorts
00:58
Бискас
Рет қаралды 5 МЛН
Amazing weight loss transformation !! 😱😱
00:24
Tibo InShape
Рет қаралды 67 МЛН
Create an API to get data from your DynamoDB Database
20:17
Complete Coding - Master AWS Serverless
Рет қаралды 22 М.
Deploy a SpringBoot 3 API on AWS Lambda in 10 minutes
9:16
James Eastham
Рет қаралды 8 М.
Secure API Gateway using Lambda Authorizer (NEW)
33:32
LoveToCode
Рет қаралды 22 М.
AWS API Gateway to Lambda Tutorial in Python | Build a REST API
11:17
Be A Better Dev
Рет қаралды 337 М.
What is an API Gateway?
10:19
IBM Technology
Рет қаралды 301 М.
Deploy a SpringBoot API on AWS Lambda in 10 minutes
12:16
James Eastham
Рет қаралды 31 М.
Частая ошибка геймеров? 😐 Dareu A710X
1:00
Вэйми
Рет қаралды 5 МЛН
Хакер взломал компьютер с USB кабеля. Кевин Митник.
0:58
Последний Оплот Безопасности
Рет қаралды 2,4 МЛН
Это iPhone 16
0:52
Wylsacom
Рет қаралды 1,3 МЛН
Сколько реально стоит ПК Величайшего?
0:37