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}
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 )
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
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 ??
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.
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.
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.
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.
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.
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!!!
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.
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.
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
@@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.
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) ruclips.net/video/5a2LS7gNECk/видео.html I've not done a video on adding EFS to lambda yet
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.
Just added it to the description but here they are for you. starting code: github.com/SamWSoftware/ServerlessRUclipsSeries/tree/lesson2-S3 final code: github.com/SamWSoftware/ServerlessRUclipsSeries/tree/lesson3-api
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}
You saved me from going off the rails, thank you! This should probably be stickied at the top.
Yes, there's a v2 of serverless now which has made the inclusion of httpApi. You should still be able to use "http" though
@@rayandwayne3275 Glad that you found it useful
the bestttt video series ever for js developers!! thank you!
Wow, thanks!
Great simple and clear.. that is what I was looking for, tutorials that go straight to the point .. thank you
Glad it was useful :)
Great training videos series! I'm currently studying for developer associate and this is helping cement the concepts.
Glad it was helpful!
These are amazing tutorials. You should consider opening a course on Udemy. You are way better than those AWS Udemy instructors.
I've done one small course on Udemy but I'm considering doing a RUclips SaaS build series and then adding extra details and putting it on Udemy too.
Thanks Sam for the great video.
My pleasure!
Great tutorial - thank you so much
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 )
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
Wow man! Thats really helpful, I really appreciate your effort what you're putting...Thanks a lot!
Glad it was helpful!
Thank you thank you thank you very much sir for this video
Thanks for commenting on all my videos :) It really helps share them to more people
Thank you for the video. It didn't show me a link to check this function. Where can I find my link?
Thank you very much for this amazing video!
You're very welcome!
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 ??
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.
Awesome video!
I was wonder, do you prefer working with js or typescript?
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.
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.
Glad that it was helpful
Thx for good video again!
Thanks for watching!
Great video
Glad you enjoyed it
Starting to watch
Hope you enjoy it
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.
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.
Great video, do you know an example of applying idempotency to the api to avoid repeated requests?
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.
@@CompleteCoding ok thanks a lot for explaining
All... Excelent!!
Thank you! Cheers!
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!!!
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.
@@CompleteCoding Thank you!!! Best tutorial
Sir I did upto deployment....after i'm open the url and it show "Missing Authentication Token"
That means that either you're probably on the wrong url.
great video!
Glad you enjoyed it
Keep it up!
That's the plan!
I believe the response object in API Gateway has changed;
status -> statusCode
now we have a property isBase64Encoded that we can set to false
Yes, it should be statusCode now :) Nice spot
Hello sir how to perform in vscode all those cli commands
You can open the terminal in VS Code using "View > Terminal" or there are shortcuts. This then works as any other terminal would do.
Whenever I deploy and open the url I get an internal server error how do we fix it ?
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.
Excellent video !
Could you make video on how building a deployment package using serverless and python?
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
@@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.
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) ruclips.net/video/5a2LS7gNECk/видео.html
I've not done a video on adding EFS to lambda yet
@@CompleteCoding thank you mate
Getting to enter path(0), path(1) after entering sls deploy... Wt to do?
I've not seen that error before. Have you entered the path for the endpoints in the serverless.yml file?
use
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.
Heloo
Wt was extension needed for serverless. Yml file?
You don't need any vs code extensions to use serverless.yml files
Is your demo source code on Github?
Just added it to the description but here they are for you.
starting code: github.com/SamWSoftware/ServerlessRUclipsSeries/tree/lesson2-S3
final code: github.com/SamWSoftware/ServerlessRUclipsSeries/tree/lesson3-api