Hey Solomon, there is a way but you need to either make the field you want to sort by a "Sort Key" or create a secondary index specifying that field again as a "Sort Key", then with the usage of Query method you can utilise ScanIndexForward parameter to get items in order
Very useful, thanks. Had to run "npm install" before deploy after adding uuid and then yup dependencies, or it would fail on the server once API is called since after yarn alone apparently packages are not being deployed.
Would be nice to have a second part with authentication and authorization, also with some fron end fro users to request acces. Just an idea ! Thanks fro the great video
Hey dude. This video was so useful. I have one question though. Where's the DB located? When I sign up to my IAM and go to DynaoDB I do not see ProductsTable. Then where is it located?
Thanks for the great video. I got the error: The CloudFormation template is invalid: Template error: instance of Fn::GetAtt references undefined resource ProductsTable. How can I fix it?
Hey Luu, Have you got "resources" section defined in serverless.yml with correct indentations like here: github.com/ttarnowski/serverless-product-api/blob/main/serverless.yml ?
I can use that syntsx on the events within framework serverless? Mybresources on aws are deployed by terraform and just need yo creare the code for lambda function and tests And my api is a api websockets
if your resources are deployed separately you need to link them in iamRoleStatements to give lambdas permissions to access them. If your api is websockets it works differently to the one presented in the video. Although I'll have a new video out soon specifically about API Gateway Websockets. I hope it'll help :)
I'm a big fan of TDD myself and very often use this approach in my professional work, so yeah definitely there will be videos in the future where I build something with tests.
Hi bro, I have a company as AWS solutions architect, I am still in training, I dont have knowledge of html/css/js/node.js rest-api dynamo.db, is it necessary for me to learn all these then create a application and test in AWS ?
Can you explain why you use .promise() but don't set that promise to a variable to process fulfilled/rejected states? For example, in createProduct() you have: await docClient .put({ TableName: tableName, Item: product, }) .promise(); You add it at 15:30, but I don't really understand what the .promise() is doing
hey Matt, very good question ".promise()" method is a part of AWS SDK and it turns entire expression's result (in this case docClient.put(...)) into a javascript Promise object, so you can use either older .then(), .catch() syntax or new async await. If I hadn't put .promise() after "put" method I wouldn't have been able to await for this operation to complete. Here's also good explanation in AWS docs with older syntax hopefully it'll help you to grasp it: docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/using-promises.html And here how to rewrite .then(), .catch() to async-await: developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await#rewriting_promise_code_with_asyncawait
@@tomasztarnowski4434 ah, ok! So if that async docClient.put() call fails, would the catch block (that eventually) wraps it catch the error? what would happen if it was never wrapped in a try/catch block? (thanks for your help!!)
if you want to catch that error and have some specific response sent from lambda you can put it in a try-catch block however if you don't in aws lambda environment it is going to fail, log an error in cloudwatch and respond with 500 status code and generic internal server error response body :)
each time I deploy using serverless deploy I get this error after some time loading Serverless: Uploading service products-api.zip file to S3 (16.88 MB)... Serverless: Recoverable error occurred (Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.), sleeping for ~5 seconds. Try 1 of 4 I searched everywhere and no solution
Hey, no, for lambda function you don't need to use express as it's a simple function that takes a request object and is supposed to return a response object. However you can still use express.js syntax if you'd like by using this wrapper library: github.com/vendia/serverless-express.
I wouldn't say it gets abandoned. They have a maintenance policy in place: docs.aws.amazon.com/sdkref/latest/guide/maint-policy.html also, there's a communication channel for any deprecation updates
Thank you man, you saved me hours of study
Glad I could help!
@@tomasztarnowski4434 is there a way to scan dynamodb to get the list ordered by LIFO
Hey Solomon, there is a way but you need to either make the field you want to sort by a "Sort Key" or create a secondary index specifying that field again as a "Sort Key", then with the usage of Query method you can utilise ScanIndexForward parameter to get items in order
Very useful, thanks. Had to run "npm install" before deploy after adding uuid and then yup dependencies, or it would fail on the server once API is called since after yarn alone apparently packages are not being deployed.
Would be nice to have a second part with authentication and authorization, also with some fron end fro users to request acces. Just an idea ! Thanks fro the great video
Thanks ! You validation part is very valuable ❤
Hey dude. This video was so useful. I have one question though.
Where's the DB located?
When I sign up to my IAM and go to DynaoDB I do not see ProductsTable.
Then where is it located?
Ohh Damn! The table is created in the AWS location specified in the config.
Thanks a ton :)
That is correct! I'm happy you've managed to figure this out yourself!
new sub, great video, your wallpaper is 10/10
Thank you, Martin!
Thank you .. this was a great video and got me started. great content will watch all other videos :)
glad to hear it, emi!
Thanks for the great video.
I got the error: The CloudFormation template is invalid: Template error: instance of Fn::GetAtt references undefined resource ProductsTable.
How can I fix it?
Hey Luu,
Have you got "resources" section defined in serverless.yml with correct indentations like here:
github.com/ttarnowski/serverless-product-api/blob/main/serverless.yml
?
I can use that syntsx on the events within framework serverless? Mybresources on aws are deployed by terraform and just need yo creare the code for lambda function and tests
And my api is a api websockets
if your resources are deployed separately you need to link them in iamRoleStatements to give lambdas permissions to access them.
If your api is websockets it works differently to the one presented in the video. Although I'll have a new video out soon specifically about API Gateway Websockets. I hope it'll help :)
@@tomasztarnowski4434 I'm waiting for that
Can we see a similar video which follows a aTDD approach?
I'm a big fan of TDD myself and very often use this approach in my professional work, so yeah definitely there will be videos in the future where I build something with tests.
Wow, thank you so much. Really love your tutorials. Would be really nice to create an authoriser for our API gateway!
Thank you mate!
Thank you, I'm glad you liked the video. Authentication in serverless will be most likely the next topic. There should be a new video about it soon.
Hi bro, I have a company as AWS solutions architect, I am still in training, I dont have knowledge of html/css/js/node.js rest-api dynamo.db, is it necessary for me to learn all these then create a application and test in AWS ?
Can you explain why you use .promise() but don't set that promise to a variable to process fulfilled/rejected states? For example, in createProduct() you have:
await docClient
.put({
TableName: tableName,
Item: product,
})
.promise();
You add it at 15:30, but I don't really understand what the .promise() is doing
hey Matt, very good question ".promise()" method is a part of AWS SDK and it turns entire expression's result (in this case docClient.put(...)) into a javascript Promise object, so you can use either older .then(), .catch() syntax or new async await.
If I hadn't put .promise() after "put" method I wouldn't have been able to await for this operation to complete.
Here's also good explanation in AWS docs with older syntax hopefully it'll help you to grasp it:
docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/using-promises.html
And here how to rewrite .then(), .catch() to async-await:
developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await#rewriting_promise_code_with_asyncawait
@@tomasztarnowski4434 ah, ok! So if that async docClient.put() call fails, would the catch block (that eventually) wraps it catch the error? what would happen if it was never wrapped in a try/catch block? (thanks for your help!!)
if you want to catch that error and have some specific response sent from lambda you can put it in a try-catch block however if you don't in aws lambda environment it is going to fail, log an error in cloudwatch and respond with 500 status code and generic internal server error response body :)
very simple and well explained (:
thank you, vatsal!
each time I deploy using serverless deploy I get this error after some time loading
Serverless: Uploading service products-api.zip file to S3 (16.88 MB)...
Serverless: Recoverable error occurred (Your socket connection to the server was
not read from or written to within the timeout period. Idle connections will be closed.), sleeping for ~5 seconds. Try 1 of 4
I searched everywhere and no solution
I got an error Stack [product-api-dev] does not exist
at which point do you get this error?
great tutorial
Thank you, Sasha Louis!
you're not using Express.js right?
Hey, no, for lambda function you don't need to use express as it's a simple function that takes a request object and is supposed to return a response object. However you can still use express.js syntax if you'd like by using this wrapper library: github.com/vendia/serverless-express.
Thank you so much.
thanks your tutorial
Don't use aws-sdk, its outdated. Use the modular v3 SDK.
I'll be switching to v3 SDK since it's recommended by AWS now, although this example of an serverless app is still going to work just fine with v2
@@tomasztarnowski4434 now? It's been recommended for nearly 2 years!
I've always been very conservative with using the newest versions until they reach a proper stability.
@@tomasztarnowski4434 same here. V3 has been deemed stable for long enough now though.
Agree.
Amazon SDKs tend to get very ugly and abandoned in future
I wouldn't say it gets abandoned. They have a maintenance policy in place:
docs.aws.amazon.com/sdkref/latest/guide/maint-policy.html
also, there's a communication channel for any deprecation updates