The interface on API Gateway has changed since the video was uploaded. there are 4 options in the beginning now. make sure you select REST API (the lower left one) to have the same interface as the video. Python Version: ruclips.net/video/9eHh946qTIk/видео.html Video on API authentication (a follow-up video): ruclips.net/video/V-ac_ZvdAW4/видео.html Video on Node.js Express API hosted on Elastic Beanstalk: ruclips.net/video/YJvXHr69AHg/видео.html Register/Login system with a serverless API (Part 1): ruclips.net/video/mgkgQtMplPY/видео.html Register/Login system with a serverless API (Part 2): ruclips.net/video/ReNkQ0Xkccw/видео.html
whosoever is watching in 2024. Dont forget these two steps. 1. Downgrade the node js runtime to v16. 2. change the extension of index file from .mjs to .js then It will work fine.
@@SILD90 yes i think i had to redo everything again with proper node version or try using sdk3 and node 20 also check permissions, thats a common issue
Man, I'm not sure if this will reach you, but THANK YOU SOOOOO MUUUCH!!!. Been trying for a whole week since i've started my internship and coundn't make it work a simple get request, tryed following more than 20 tutorials and documentations and more errors we're appearing, can't describe the happiness and relief that i'm feeling right now xD.
Such a huge help. I'm taking a course this semester and it's my first time I'm required to use AWS services, without much previous experience with APIs. I can't express how helpful this demo will be for me. You rock.
I just started AWS today and used your video as a starting point. Awesome, besides the differences in the AWS UI with yours and the "Missing Authentication Token" everything is going well. On AWS there are 2 options for the REST API, another way has the words (private). Thank you so much for this.
thanks man!! appreciate it....i also have a video where i talked abt how to add authentication to the api and throttle traffics. if you are interested: ruclips.net/video/V-ac_ZvdAW4/видео.html
@@FelixYu thanks i'll check it out! also... for this video, i'm getting a "message": "Internal server error" through POSTMAN, and can't seem to figure out why? I checked things like my region, which matches up. I looking through Cloudwatch logs to figure it out... any suggestions? If it helps, for some reason the GET /health works, but making a POST to /product does not work, and neither do the rest. Same error for all: "message": "Internal server error".
@@russooneateseven if it returns an error that says internal server error, it means, the lambda function error out. when u look at cloudwatch, what does it show u?? does it show u the error??
@@FelixYu after reading through the error, the productid didn't match, because I used productId. I think there's a couple places in your tutorial using camel case and not using camelcase for productid. But that's ok. It helped me understand how to use the cloudlogs! so it fixed the post and patch requests, so they all work successfully now, accept the GET /products. (I can get a single product) but I cannot get all products. It comes up with a 404 in postman. (I made sure the url and path were correct), but that's the only thing I can think of being the issue would be the wrong path due to the 404
@@russooneateseven github.com/felixyu9/serverless-api-tutorial-code/blob/main/index.js here is the source code for the lambda. you can compare ur code with this and see if there are any mismatches....or another way to do it is to clone this and then modify from it accordingly to meet ur need!!!!
thanks man!! glad that it helped 👍...i also have a video that talks about how to add authentication to the api and throttle traffics. if you are interested: ruclips.net/video/V-ac_ZvdAW4/видео.html
FIX for: "Internal server error" & "Cannot find module 'aws-sdk' You are probably using NodeJS 18x - This video was made with NodeJS 16x Go to your lambda serverless-api function Code -> scrolls down -> Runtime settings -> edit -> change to 16x Helpful stack overflow: "AWS Lambda "cannot find module aws-sdk" in Build a Basic Web Application tutorial"
I absolutely loved the way you explained everything. Thank you so much for this tutorial. I need your help as I am getting 500 Internal Server Error for the health request and there's no data in the log. I cross checked I have added the cloudwatch policy.
Absolutely amazing tutorial! Concise yet thorough and explained exactly what I need to know. I would be very interested in a video describing how to implement user authentication to control access to the API.
Thanks man , you saved me , i was stuck in a documentation reading limbo . Please create a playlist with creating a full blown backend project of like something , travelling app , food ordering app , and payments with stripe and such . Thanks man for the content , its really great . 💓
Hi Felix! Really appreciate your work, I was looking the exact tutorial. This is the exact tutorial of what I wanted but it's just that I'm not familiar with NodeJS. I wanted the code in Python.
good day sir, i have been trying to do this tutorial using my own variable but i get the same errors on line 25 and line 29 that says saveVariable is not defined please fix or add /*global saveVariable*/. can you please kindly help me to fix it. thank you in advance.
I uploaded your code to my index.js file and created the various methods, however in postman when I try and "post" a product I get: "message": "Internal server error" status 502 bad gateway. Hope someone can answer this!!
Hi Felix, for getting specific product ,delete function, and modifying function, I am getting the error 'Internal server error 502 bad gateway' Any idea why?
great tutorial! a short question, is there a good way to integrate the lambda function with git afterward? or just use serverless to do that in beginning? thanks!
I keep having a problem with validating the preflight request when I use the PATCH method is there something I can do to allow my lambda to respond with what is needed for a preflight request
Thank you felix! I have a question about the 'aws-sdk'. When I try to check my lambda function, I get a TypeError: "AWS.config is not a function". I need to download in some way the 'aws-sdk'?
This is great video... but still got "internal server error" My Mistake ✌....got typo on my script....now its work...absolutely great tutorial very easy to understand...👍👍
everything is working fine but when I try to update the data using PATCH the response is "internal server error", I tried everything but it is not working :(
that means there is an error in the lambda function. u can go to the lambda console -> monitoring -> view logs in cloudwatch and then u can see what the error is and fix it accordingly
@@jainilpatel164 Actually i am getting this error in clouwatch logs for all these methods. validationException: The provided key element does not match the schema. @felix yu if u can help that will be great.
@@ashoklamba4498 that means the primary key type u have in ur dynamodb does not match with ur request. im guessing the problem is u have productId as a string set up in dynamodb and in ur request in postman, u pass in a number. try to put a quotation mark around it (e.g., "productId": "123456"). let me know if this resolves the issue!!
Felix, this is a great tutorial and answered a lot of my questions about using an API but I have a relational database that I would like the lambda to write to instead of dynamoDB. Could you do another tutorial with a relational database in mind or do you have any resources you could point me to? Thank you for all of the great content.
Following your method, I'm experiencing CORS issues when calling the API from the browser. The problem exists even though I have set the ENABLE CORS on the API Gateway according to the official website. When the API is associated with lambda, do I need to make a separate CORS setting on the lambda side?
@@FelixYu The CORS problem occurs in the API Gateway, and I think the problem should be solved in the API Gateway. In fact, this CORS problem has been solved by adding judgment to the options method.
Great Content Felix! It seems like the code only allows to use "Patch" to update a numeric value in DynamoDB. Attempting to update a string value (e.g. color: "red") will return an error(Internal server error). Do I have to change the Lambda code for that?
that means there is an error in the lambda function. Without seeing the detailed error message, it’s hard to tell what the problem was. u can go to the lambda console -> monitoring -> view logs in cloudwatch and then u can see what the error is and fix it accordingly.
@@FelixYu Thanks man ! Turns out I was using a reserved word in my table that prevent the update. Do you have any recommendations in terms of tutorials and documentations for someone who want get into coding in Lambda? I understand you are a self-taught software engineer :)
@@yukimister87 for learning coding in general i think the best way to do it is take some online courses to learn the basics (coursera, EdX, etc.) and then build something with it....that was my approach when i got started!!
Hi Thanks for the tutorial, i tried this, however during postman api testing I only get hello from lambda as a response even when I try to post JSON data to dynamo db
thanks Felix great tutorial, however, I have met some problems when I'm using PATCH method. Following your code, I can update it with number very easily but with string or other data type it is not working and it responses message: "Internal server error". Can you help me with that. Thank you in advance.
that means theres an error in the lambda function. u can go to the lambda console -> monitoring -> view logs on cloudwatch and see what the error is and then fix it accordingly. my guess is u set the dynamodb primary key type to be number (3:03 of the video) and u tried it set it as string, which is now allowed.
i am getting this type of error what to do region is same that show in your video error is --------->The specific log group: /aws/lambda/serverless-api does not exist in this account or region.
Sir, I am trying to build the API but the AWS API interface is different from what is shown in this video. I did create API but on invoking the methods via postman, lambda function code sends '404 Not Found'. I see that event.httpMethod and event.path are coming out to be NULL. I changed the code to use event.requestContext.http.method, event.requestContext.http.path. I see it working. My Question is, what controls the order of fields when inserting and selecting from dynamodb table; Apparently , the order is different. Thank you for the video.
yea i think the interface in the beginning has changed....i think u might have selected a different api type when u created it. There are 4 options....make sure u select REST API (the lower left one) and u should be able to follow the video as is.
Please help. This tutorial is great. However I cannot make POST work. I can add an item directly into my dynamodb table and every single method works except for POST. When I try to add a product with the POST method I get the default 404 error (or null if I remove the unnecessary default case). So for some reason seems as if the POST && PATH case is never met. But I can't figure out why. PLEASE!!!!
@@FelixYu thank you for the reply. I did a copy/paste from the provided source code the first time I got the error and it still persisted. However I did manage to get it working. After some Google-Fu I found that redeployment of the API was the fix. My guess is that was needed after editing the code. So it works perfectly now. Thank you again for this tutorial. Super awesome. If you have a video of a way to make this work with a website front-end I'd appreciate the link. Ultimately trying to complete an RSVP section of my wedding website, and want to preload the "contact" form using a unique code for each guest.
@@DaleQuaife03 I have two videos (frontend and backend) where I talked abt how to build an authentication website that may be similar to what you are looking for. check them out: ruclips.net/video/mgkgQtMplPY/видео.html ruclips.net/video/ReNkQ0Xkccw/видео.html
Hi @Felix Yu , the video was very informative. I tried to replicate the steps as mentioned in your video.But while running the API gateway url in postman I'm getting 502 bad gateway,, can you please help why?
that means the endpoint is incorrect....make sure u copy the url from the right stage on api gateway and then add /health, /product or products to the end....also make sure u use the right request method on postman (e.g., get , post, etc.)
No matter what I try to do, I keep receiving a 502 Bad gateway with a "Internal server error" message even when I put the code from the video in my lambda :/ (tried switching to node 16 and no change either) Does someone know how to fix it ? Thanks
u can modify the method to take in multiple update keys and values in a list in the request body and handle them accordingly..such as { productId: '1001', updateItems: [ { key: 'key1', value: 'value1' }, { key: 'key2', value: 'value2' } ] }
I am getting "message": "Credential should be scoped to a valid region, not 'us-east-1'. " when using GET request for /products API, for authentication I have added the secret and access key in AWS Signature under Postman-> Authorization section. What could be the possible reason? Could you provide your email id for quick response
when u defined ur AWS config in ur lambda code, make sure u set it to the region where ur DynamoDB table is (i think i mistakenly said lambda in the video). refer to 11:28 of the video. let know if that works
also u shouldn't need to include the secret and access key in postman for the API call. it is open to the world by default. if you wanna restrict access to the API, refer this this video for an additional simple step!! ruclips.net/video/V-ac_ZvdAW4/видео.html
that means there is an error in the lambda function. u can go to the lambda console -> monitoring -> view logs in cloudwatch and then u can see what the error is and fix it accordingly
here is the source code for the lambda function. try to copy that and modify it accordingly: github.com/felixyu9/serverless-api-tutorial-code/blob/main/index.js
@Felix Yu. Great work. Congrats !!! When I try to check my API health, I am getting {"message":"Missing Authentication Token"} as a response. Is it possible to point me in the right direction on how to overcome this error, please? Really appreciate your help. Thank you
If you are uploading to a S3 bucket, then I would use pre sign urls. Setup an endpoint to a lambda that can create a pre sign url and return to the client, and then use that url to upload the file direct to the S3. With this method you can bypass the file size limits that lambda and api gateway have.
u can pass in an object that contains key value pairs that u wanna update. for example: { "price": 20, "color": "black", "somethingElse": 100 } and then in ur lambda function u can have a for loop to go thru each one to construct the query string: set price=:value1, color=:value2, somethingElse=:value3 and then in ur ExpressionAttributeValues, u define :value1, :value2, value3 as 20, "black" and 100, respectively
The interface on API Gateway has changed since the video was uploaded. there are 4 options in the beginning now. make sure you select REST API (the lower left one) to have the same interface as the video.
Python Version: ruclips.net/video/9eHh946qTIk/видео.html
Video on API authentication (a follow-up video): ruclips.net/video/V-ac_ZvdAW4/видео.html
Video on Node.js Express API hosted on Elastic Beanstalk: ruclips.net/video/YJvXHr69AHg/видео.html
Register/Login system with a serverless API (Part 1): ruclips.net/video/mgkgQtMplPY/видео.html
Register/Login system with a serverless API (Part 2): ruclips.net/video/ReNkQ0Xkccw/видео.html
I wonder why your comment is not on the top
whosoever is watching in 2024.
Dont forget these two steps.
1. Downgrade the node js runtime to v16.
2. change the extension of index file from .mjs to .js
then It will work fine.
thank you so much!! saved me the trouble to try find the error before even appearing xD
doenst work for me
still getting 502 bad gateway
@@elClubdelas7Cifras did you fix it? I'm having the same problem
@@SILD90 yes
i think i had to redo everything again with proper node version
or try using sdk3 and node 20
also check permissions, thats a common issue
@@elClubdelas7Cifras
Do You wrote in Node js 20x. I have tried but it's not working.
Man, I'm not sure if this will reach you, but THANK YOU SOOOOO MUUUCH!!!. Been trying for a whole week since i've started my internship and coundn't make it work a simple get request, tryed following more than 20 tutorials and documentations and more errors we're appearing, can't describe the happiness and relief that i'm feeling right now xD.
Such a huge help. I'm taking a course this semester and it's my first time I'm required to use AWS services, without much previous experience with APIs. I can't express how helpful this demo will be for me. You rock.
Glad that it’s helpful :)
glad to know I was on the right path with this. once you get over the confusion of handlers this stuff becomes really simple.
Glad that u found it helpful!!
I just started AWS today and used your video as a starting point. Awesome, besides the differences in the AWS UI with yours and the "Missing Authentication Token" everything is going well. On AWS there are 2 options for the REST API, another way has the words (private). Thank you so much for this.
after reading a bunch of how to's and getting confused, this was a great step by step tutorial to watch
thanks man!! appreciate it....i also have a video where i talked abt how to add authentication to the api and throttle traffics. if you are interested:
ruclips.net/video/V-ac_ZvdAW4/видео.html
@@FelixYu thanks i'll check it out! also... for this video, i'm getting a "message": "Internal server error" through POSTMAN, and can't seem to figure out why? I checked things like my region, which matches up. I looking through Cloudwatch logs to figure it out... any suggestions? If it helps, for some reason the GET /health works, but making a POST to /product does not work, and neither do the rest. Same error for all: "message": "Internal server error".
@@russooneateseven if it returns an error that says internal server error, it means, the lambda function error out. when u look at cloudwatch, what does it show u?? does it show u the error??
@@FelixYu after reading through the error, the productid didn't match, because I used productId. I think there's a couple places in your tutorial using camel case and not using camelcase for productid. But that's ok. It helped me understand how to use the cloudlogs! so it fixed the post and patch requests, so they all work successfully now, accept the GET /products. (I can get a single product) but I cannot get all products. It comes up with a 404 in postman. (I made sure the url and path were correct), but that's the only thing I can think of being the issue would be the wrong path due to the 404
@@russooneateseven github.com/felixyu9/serverless-api-tutorial-code/blob/main/index.js
here is the source code for the lambda. you can compare ur code with this and see if there are any mismatches....or another way to do it is to clone this and then modify from it accordingly to meet ur need!!!!
Thanks dude. This was an excellent tutorial. I created APIs with POST and GET methods before. Been looking for full CRUD tutorial
thanks man!! glad that it helped 👍...i also have a video that talks about how to add authentication to the api and throttle traffics. if you are interested:
ruclips.net/video/V-ac_ZvdAW4/видео.html
FIX for: "Internal server error" & "Cannot find module 'aws-sdk'
You are probably using NodeJS 18x - This video was made with NodeJS 16x
Go to your lambda serverless-api function
Code -> scrolls down -> Runtime settings -> edit -> change to 16x
Helpful stack overflow:
"AWS Lambda "cannot find module aws-sdk" in Build a Basic Web Application tutorial"
Excellent demo of a real-world use-case of Lambda with Application Integration.
This was exactly what I needed! Keep it going please!
Thanks man!!
Thanks for the video Felix. Please upload more videos on aws covering other services. Love the content.
I absolutely loved the way you explained everything. Thank you so much for this tutorial.
I need your help as I am getting 500 Internal Server Error for the health request and there's no data in the log. I cross checked I have added the cloudwatch policy.
Best Serverless API tutorial
Thank you :)
Wow! One of the best tutorials! Great tutorial! Felix! Did thumbs up on the video!
glad that it helped :)
Absolutely amazing tutorial! Concise yet thorough and explained exactly what I need to know. I would be very interested in a video describing how to implement user authentication to control access to the API.
thank you sir!!!! the user authentication video will be out soon (should be within the next couple of wks) 👍
@@FelixYu Awesome; thanks for the reply. Your video really helped with a project I'm working on.
the api authentication video is out. check it out
ruclips.net/video/V-ac_ZvdAW4/видео.html
The best tutorial I have seen. Thanks, Felix Yu
glad that it helped 👍
Thank you, Felix, clearly explained!
Glad that you found it helpful 👍
Thanks man , you saved me , i was stuck in a documentation reading limbo . Please create a playlist with creating a full blown backend project of like something , travelling app , food ordering app , and payments with stripe and such . Thanks man for the content , its really great . 💓
thank you thank you!!!! ill look into these....thanks for the suggestions!!!! 👍
Really appreciate your work, I was looking for the exact tutorial.
Looking forward for authentication
thank you. here is the authentication video. check it out!!
ruclips.net/video/V-ac_ZvdAW4/видео.html
Expecting more like this
Hi Felix!
Really appreciate your work, I was looking the exact tutorial.
This is the exact tutorial of what I wanted but it's just that I'm not familiar with NodeJS.
I wanted the code in Python.
here is the python version video: ruclips.net/video/9eHh946qTIk/видео.html
extremely useful, and comprehensive video. Thanks!
Very Well Explained. Great Work Felix!
thank you!!
Where I can get the code which you written during build up API gate?
Thank you Felix Yu for amazing video. Your fan now :)
glad that it helped 👍
Thanks Felix. I have Lambda, Gateway and Dynamo already, but inactive for a year. I have time now to update and make it big.
Nicee!!
Very appreciate the tutorial, thanks for uploading
Glad that you found it helpful 👍
Thank you, Felix! Very helpful video!
This is really nice and easy to understand. Thank you.
Felix: Your work here is outstanding. Check out the API Keys lesson in the description!
Thank you for sharing wonderful content, executed perfectly.
Glad that it’s helpful 👍
Great vid man. Keep up the good work.
Thanks a lot Felix.. wonderful explanation :)
I am glad that u found it helpful!! 👍
good day sir, i have been trying to do this tutorial using my own variable but i get the same errors on line 25 and line 29 that says saveVariable is not defined please fix or add /*global saveVariable*/. can you please kindly help me to fix it. thank you in advance.
i managed to fix the problem...thank you for this tutorial
@@cheyezamlondo7933 how did you fix the problem?
@@ritwiksrivastava6862 he added the word global which means variable can now be accessed from outside the func
This is amazing! Thanks for putting this up.
Glad you enjoyed it!
I uploaded your code to my index.js file and created the various methods, however in postman when I try and "post" a product I get: "message": "Internal server error" status 502 bad gateway. Hope someone can answer this!!
That means there’s an error in the lambda function..u can go to cloudwatch and see what the error is
@@FelixYu downgrade node 18 to node 16
What if I have a huge code base, with multiple files/modules, how do I keep that in sync with the code on my lambda and deploy continuously?
I'm getting 502 bad gateway. Unable to resolve this issue. Please help
Check your CloudWatch logs to debug. For me, it was silly ES6 module export error.
Best api tutorial ever ! Would appreciate if you can add Cognito in a new tutorial :)
this video is very useful. Thank you!
Glad that u found it helpful!!
Wow , keep it up 👍🏻
Tutorial is really helpful. Thanks
bundle of thanks .. really awsome video ..
Hi Felix, for getting specific product ,delete function, and modifying function, I am getting the error 'Internal server error 502 bad gateway' Any idea why?
downgrade node 18 to node 16
Guys who ever getting *internal server error* change region in code
make sure proxy lambda integration is checked while creating resource and method in API Gateway
great tutorial!
a short question, is there a good way to integrate the lambda function with git afterward?
or just use serverless to do that in beginning?
thanks!
ruclips.net/video/AmHZxULclLQ/видео.html
I have a diff video that talks abt how to integrate lambda with github. Check it out
I keep having a problem with validating the preflight request when I use the PATCH method is there something I can do to allow my lambda to respond with what is needed for a preflight request
Thank you so much this is just what I needed
@FlixYu do you often use console in your work?
What if services has 100 endpoints? Should one write all the functions in one lambda function? What is the best approach?
Thank you felix!
I have a question about the 'aws-sdk'.
When I try to check my lambda function, I get a TypeError: "AWS.config is not a function".
I need to download in some way the 'aws-sdk'?
Nope u don’t needa download the aws-sdk cuz it’s built in. Make sure u don’t have a typo in the require statement
obviously config is not a function its and object which provide update function
Thanks for this tutorial!
This is great video... but still got "internal server error"
My Mistake ✌....got typo on my script....now its work...absolutely great tutorial very easy to understand...👍👍
glad that u found it helpful!!
everything is working fine but when I try to update the data using PATCH the response is "internal server error", I tried everything but it is not working :(
that means there is an error in the lambda function. u can go to the lambda console -> monitoring -> view logs in cloudwatch and then u can see what the error is and fix it accordingly
I am also getting same error in PATCH, DELETE,GET methods in product resource, if you have resolved plzz explain
@@ashoklamba4498 I had problem with lambda function in the patch section, it was resolved when I corrected the code.
@@jainilpatel164 Actually i am getting this error in clouwatch logs for all these methods. validationException: The provided key element does not match the schema. @felix yu if u can help that will be great.
@@ashoklamba4498 that means the primary key type u have in ur dynamodb does not match with ur request. im guessing the problem is u have productId as a string set up in dynamodb and in ur request in postman, u pass in a number. try to put a quotation mark around it (e.g., "productId": "123456"). let me know if this resolves the issue!!
Felix, this is a great tutorial and answered a lot of my questions about using an API but I have a relational database that I would like the lambda to write to instead of dynamoDB. Could you do another tutorial with a relational database in mind or do you have any resources you could point me to? Thank you for all of the great content.
Why my post method of product is not working and giving configuration error
Following your method, I'm experiencing CORS issues when calling the API from the browser. The problem exists even though I have set the ENABLE CORS on the API Gateway according to the official website. When the API is associated with lambda, do I need to make a separate CORS setting on the lambda side?
did u allow CORS in ur lambda function as well??
@@FelixYu The CORS problem occurs in the API Gateway, and I think the problem should be solved in the API Gateway. In fact, this CORS problem has been solved by adding judgment to the options method.
I'm getting an error while creating product api..
{
"message": "Missing Authentication Token"
}
Im also going through this just now and experiencing the same issue.
@@anelembanga6061 have u got with any luck?
why not a lambda for each HTTP method?
I am wondering about this too. This breaks the single responsibility principle doesn’t it?
Great Content Felix! It seems like the code only allows to use "Patch" to update a numeric value in DynamoDB. Attempting to update a string value (e.g. color: "red") will return an error(Internal server error). Do I have to change the Lambda code for that?
that means there is an error in the lambda function. Without seeing the detailed error message, it’s hard to tell what the problem was. u can go to the lambda console -> monitoring -> view logs in cloudwatch and then u can see what the error is and fix it accordingly.
@@FelixYu Thanks man ! Turns out I was using a reserved word in my table that prevent the update. Do you have any recommendations in terms of tutorials and documentations for someone who want get into coding in Lambda? I understand you are a self-taught software engineer :)
@@yukimister87 for learning coding in general i think the best way to do it is take some online courses to learn the basics (coursera, EdX, etc.) and then build something with it....that was my approach when i got started!!
@@FelixYu Many Thanks Felix !
Is that good practice to create all crud operations in single lambda function?
no
Hi Thanks for the tutorial, i tried this, however during postman api testing I only get hello from lambda as a response even when I try to post JSON data to dynamo db
I figured out the issue, Thanks your content is great. Please make more practical videos on AWS serverless.
@@DKs_Delight please told me how did you figure it out i am getting the same hello from lambda as response
Outstanding buddy.
glad that you found it helpful 👍
Very useful tutorial, thank you
Glad that it helped..feel free to check out my other videos as well 👍
thanks Felix great tutorial, however, I have met some problems when I'm using PATCH method. Following your code, I can update it with number very easily but with string or other data type it is not working and it responses message: "Internal server error". Can you help me with that. Thank you in advance.
that means theres an error in the lambda function. u can go to the lambda console -> monitoring -> view logs on cloudwatch and see what the error is and then fix it accordingly. my guess is u set the dynamodb primary key type to be number (3:03 of the video) and u tried it set it as string, which is now allowed.
Wonderful video!
Thanks a lot for this wonderful video.
glad that u found it helpful!! 👍
Hi Felix Yu, great video can u share ur website where it explained more, website is not working
i am getting this type of error what to do region is same that show in your video error is --------->The specific log group: /aws/lambda/serverless-api does not exist in this account or region.
I think u might have forgot to add the cloud watch policy to it. Make sure u add the 2 policies I added in 4:32 of the video
Sir, I am trying to build the API but the AWS API interface is different from what is shown in this video. I did create API but on invoking the methods via postman, lambda function code sends '404 Not Found'. I see that event.httpMethod and event.path are coming out to be NULL. I changed the code to use event.requestContext.http.method, event.requestContext.http.path. I see it working. My Question is, what controls the order of fields when inserting and selecting from dynamodb table; Apparently , the order is different. Thank you for the video.
yea i think the interface in the beginning has changed....i think u might have selected a different api type when u created it. There are 4 options....make sure u select REST API (the lower left one) and u should be able to follow the video as is.
amazing video.. loved it
Glad that it’s helpful 👍
Can you tell me someone, in this operation where he used IAM role?
Felix, thank you so much for this high quality instruction video. /ben
Glad that it helped 👍
Very details and nice video! Would you please share something about how to secure the Lambda function? Thank you!
here is a video on how to secure ur api via api keys (i.e., u can only access the api if u have an api key):
ruclips.net/video/V-ac_ZvdAW4/видео.html
Please help. This tutorial is great. However I cannot make POST work. I can add an item directly into my dynamodb table and every single method works except for POST. When I try to add a product with the POST method I get the default 404 error (or null if I remove the unnecessary default case). So for some reason seems as if the POST && PATH case is never met. But I can't figure out why. PLEASE!!!!
Try to get the source code in the description section and start from there and then modify it accordingly. Ur error was prob caused by typos
@@FelixYu thank you for the reply. I did a copy/paste from the provided source code the first time I got the error and it still persisted. However I did manage to get it working. After some Google-Fu I found that redeployment of the API was the fix. My guess is that was needed after editing the code. So it works perfectly now. Thank you again for this tutorial. Super awesome. If you have a video of a way to make this work with a website front-end I'd appreciate the link. Ultimately trying to complete an RSVP section of my wedding website, and want to preload the "contact" form using a unique code for each guest.
@@DaleQuaife03 I have two videos (frontend and backend) where I talked abt how to build an authentication website that may be similar to what you are looking for. check them out:
ruclips.net/video/mgkgQtMplPY/видео.html
ruclips.net/video/ReNkQ0Xkccw/видео.html
Amazing content!
Thanks man!!
Hi @Felix Yu , the video was very informative. I tried to replicate the steps as mentioned in your video.But while running the API gateway url in postman I'm getting 502 bad gateway,, can you please help why?
That means there’s any error in the lambda function. U can check the lambda log and see what it is
Were you able to fix the error, please?
downgrade node 18 to node 16
@@Omanshuaman may ik how u did?
Good stuff
I'm getting missing authentication token error in postman after doing exact what has been shown. How to fix it?
that means the endpoint is incorrect....make sure u copy the url from the right stage on api gateway and then add /health, /product or products to the end....also make sure u use the right request method on postman (e.g., get , post, etc.)
@@FelixYu yeah it worked. i copied wrong url. thanks man!
Excellent tutorial
No matter what I try to do, I keep receiving a 502 Bad gateway with a "Internal server error" message even when I put the code from the video in my lambda :/
(tried switching to node 16 and no change either)
Does someone know how to fix it ?
Thanks
are you have answer?
I fix this error, in my case you have to change the region variable at the beggining of the code.
got same error
@@cesarzapata24 already tried but no luck
This AWS Dynamo Lamdba stuff is complete dogshit even amazon's own code samples don't work
Hi,
Links to Lambda and DynamoDB has expired, can you update those?
how do you patch multiple updateKeys?
u can modify the method to take in multiple update keys and values in a list in the request body and handle them accordingly..such as
{
productId: '1001',
updateItems: [
{
key: 'key1',
value: 'value1'
},
{
key: 'key2',
value: 'value2'
}
]
}
I am getting "message": "Credential should be scoped to a valid region, not 'us-east-1'. " when using GET request for /products API, for authentication I have added the secret and access key in AWS Signature under Postman-> Authorization section. What could be the possible reason? Could you provide your email id for quick response
when u defined ur AWS config in ur lambda code, make sure u set it to the region where ur DynamoDB table is (i think i mistakenly said lambda in the video). refer to 11:28 of the video. let know if that works
also u shouldn't need to include the secret and access key in postman for the API call. it is open to the world by default. if you wanna restrict access to the API, refer this this video for an additional simple step!!
ruclips.net/video/V-ac_ZvdAW4/видео.html
Did you use Node js to write the lambda functions?
yes
Great video !
Thanks a lot
glad that u found it helpful!!
Instead of so many condition checks why not have different lambda function for each api request, segregate the functionality ? Less execution time .
I think it's possible to write same lambda function in python as i am beginner in coding
Plz reply
ruclips.net/video/9eHh946qTIk/видео.html
here is the python version of it
I keep getting a 502 bad gateway Internal Server Error. And I did this twice, I must have made the same mistake twice some where.
that means there is an error in the lambda function. u can go to the lambda console -> monitoring -> view logs in cloudwatch and then u can see what the error is and fix it accordingly
How do I write the code in line number 102? I am getting an error, please help me
here is the source code for the lambda function. try to copy that and modify it accordingly:
github.com/felixyu9/serverless-api-tutorial-code/blob/main/index.js
Thank you so much
Just found your channel really looking forward to digging into this. Sub'd
@Felix Yu. Great work. Congrats !!! When I try to check my API health, I am getting {"message":"Missing Authentication Token"} as a response. Is it possible to point me in the right direction on how to overcome this error, please? Really appreciate your help. Thank you
When u created the api in api gateway, I think u have 4 options in the beginning. Did u choose the REST API option? It’s the lower left corner one
@@FelixYu Appreciate your prompt reply. Many thanks. I am not sure. I will do it again and let you know. Again, thank you very much!!!
Thank you it is very helpful
Glad it was helpful!
great video ...
Felix, thank you it's really wonderful. How can i get the code, can you pls create a repo, it will be helpful
here is the source code: github.com/felixyu9/serverless-api-tutorial-code/blob/main/index.js
@@FelixYu Thanks for short reply
Can you create file upload api using nodejs serverless daynomadb,I have urjunt requirment
If you are uploading to a S3 bucket, then I would use pre sign urls. Setup an endpoint to a lambda that can create a pre sign url and return to the client, and then use that url to upload the file direct to the S3. With this method you can bypass the file size limits that lambda and api gateway have.
how to update multiple attribute in same query ? please
u can pass in an object that contains key value pairs that u wanna update. for example:
{
"price": 20,
"color": "black",
"somethingElse": 100
}
and then in ur lambda function u can have a for loop to go thru each one to construct the query string: set price=:value1, color=:value2, somethingElse=:value3
and then in ur ExpressionAttributeValues, u define :value1, :value2, value3 as 20, "black" and 100, respectively
nice job!
Thank you so much 👌