Hey Sam, just wanted to say I really enjoyed your videos so far. This area of coding is missing some good old fashioned explanations and examples, and you fill the gap perfectly. Looking forward to more content!
for people getting dynamobd.documentclient is not a constructor in the lambda function logs use, var documentClient = new AWS.DynamoDB.DocumentClient({apiVersion: '2012-08-10'});
Thanks Jax. Serverless is so powerful and flexible. There are projects I've down with clients where we build in 3 days a product that would have been months of work without serverless.
Hi Sam, I am getting the following error: `await is only valid in async function ` The above error is for `const user = await Dynamo.get(ID, tableName).catch(err => {.....` Excellent videos. These are really helpful.
Thanks Alex. I don't have a patreon page but liking and commenting on the videos is a great way to help me out. Checked out your videos too, they're really good and clear. Keep up the great work
Hi Sam, I hope you are doing well. In the get response of my lambda call, I get undefined text being returned for those values which are null/empty in DynamoDB. Is there a way for me to ignore/not pass these values as a part of my get response.
There isn't a way that I know if in Dynamo to do this, but you can easily do it in code. Object.entries(data).map(([key, value]) => value === null && delete data[key]) or you could convert this to a function const removeNull = data => { Object.entries(data).map(([key, value]) => value === null && delete data[key]) return data }
Great video! What if I have an application that interacts w/ dynamodb through lambda, and I get ProvisionedThroughputExceededException when in actuality dynamadb is not producing such error. Any suggestion please?
That means that your dynamo is probably set to "provisioned capacity" and you're using more than what is set. If you've set a read capacity of 1, that's about 2 requests up to 4kb per second. If you try and do a third you'll get that error. To fix this either increase the capacity or change the table to be 'on demand'. It costs more but scales super fast and doesn't cost you when you're not using it.
@@CompleteCoding I thought about what you said, but the provisioned throughput exceeded exception is not in the Dynamodb log. It's only the application reporting the error erroneously. I wonder if permission issues would cause that.
@@renejacques8288 I would be surprised if a permissions issue would return that error message. googling that error message always says that it's a Dynamo capcity issue.
@@CompleteCoding OK. By chance would you know any good study video/material for someone going for the AWS solutions architect and the developer's associate exams?
@@renejacques8288 Go to Udemy and search for the exam you're taking. There are some with thousands of 5* reviews. The ones I've done previously will be out of date now
First check out my video on creating a POST endpoint ruclips.net/video/AguTaMQGACE/видео.html Using that video, you would just need to change the logic in your Lambda. The event body will now be an array of objects so you can do something like: const arrayOfNewUsers = JSON.parse(event.body) const promiseArray = arrayOfNewUsers.map(async (user) => { const newUser = await Dynamo.write(user, tableName) return newUser }); const users = await Promise.all(promiseArray); If you pass three objects in the array, it will 'map' over them and each one will write to dynamo. You end up with three promises so you just use 'Promise.all' to make sure they all succeed.
You could use a Scan. This is not advised though as it isn't a very optimised request. You also only get back the first 1MB of data, and then you'd have to subsequently make requests until you've got the whole table. The other way is to query each index in your table. Either way it's not a process that you want to be doing. Maybe you could redesign your app so you don't have to read a whole table at once.
@@CompleteCoding thank you for the scan option..i also figured out that scan was an option to fetch the whole data contents- if I need to plot in a table..but if i need to plot entity wise or date wise i'll use query thanks for the tips
I get a response to 502 bad gateway for several times trying. I don't know what happened. I sure the code is the same with this tutorial. Somebody can help me? thanks.
If you go into the lambda in the AWS console and the 'monitoring' tab. Have a look at the recent invocations. You should be able to see anything that is console.log() in the code. This should point you in the right direction
I've not got any Python code I can share at the moment but this page has a lot of good starter Python code docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.Python.03.html
Hey Sam, just wanted to say I really enjoyed your videos so far. This area of coding is missing some good old fashioned explanations and examples, and you fill the gap perfectly. Looking forward to more content!
Thanks Omer, glad you're enjoying the content
Thanks Sam! I'm going over all your videos. Really nice!
Thanks Jean. I'm glad you're finding them useful
I feel I am lucky that I found this playlist.
From your comments it feels like you've watched the whole way through!
@@CompleteCoding yes Indeed!
Same
I'm loving this whole series
Really glad to head that
for people getting dynamobd.documentclient is not a constructor in the lambda function logs use, var documentClient = new AWS.DynamoDB.DocumentClient({apiVersion: '2012-08-10'});
Nice spot
Thanks! :)
loving you vids Sam.. really eye operning what you can do with serverless + aws
watching all of your vids now :-)
Thanks Jax. Serverless is so powerful and flexible.
There are projects I've down with clients where we build in 3 days a product that would have been months of work without serverless.
Splendid Man!! thanks a lot.
My pleasure
Can you do more videos like this :)
can you do a complete Project video that will help allot
Hi Sam, I am getting the following error:
`await is only valid in async function `
The above error is for `const user = await Dynamo.get(ID, tableName).catch(err => {.....`
Excellent videos. These are really helpful.
Got it. I didn't declare the handler function in getUser as async. :D
I've done this so many times. I've now set up vs code snippets to set up new handlers
In new serverless version the correct way is:
iam:
role:
statements:
- Effect: "Allow"
Action:
- "dynamodb:*"
Resource: '*'
You should still be able to do the method shown with serverless V3.
This is really valuable content! Where's your patreon page?
Thanks Alex. I don't have a patreon page but liking and commenting on the videos is a great way to help me out. Checked out your videos too, they're really good and clear. Keep up the great work
Excellent ! thank you!
Glad you liked it!
Hi Sam, I hope you are doing well. In the get response of my lambda call, I get undefined text being returned for those values which are null/empty in DynamoDB. Is there a way for me to ignore/not pass these values as a part of my get response.
There isn't a way that I know if in Dynamo to do this, but you can easily do it in code.
Object.entries(data).map(([key, value]) => value === null && delete data[key])
or you could convert this to a function
const removeNull = data => {
Object.entries(data).map(([key, value]) => value === null && delete data[key])
return data
}
Great video! What if I have an application that interacts w/ dynamodb through lambda, and I get ProvisionedThroughputExceededException when in actuality dynamadb is not producing such error. Any suggestion please?
That means that your dynamo is probably set to "provisioned capacity" and you're using more than what is set.
If you've set a read capacity of 1, that's about 2 requests up to 4kb per second. If you try and do a third you'll get that error.
To fix this either increase the capacity or change the table to be 'on demand'. It costs more but scales super fast and doesn't cost you when you're not using it.
@@CompleteCoding I thought about what you said, but the provisioned throughput exceeded exception is not in the Dynamodb log. It's only the application reporting the error erroneously. I wonder if permission issues would cause that.
@@renejacques8288 I would be surprised if a permissions issue would return that error message.
googling that error message always says that it's a Dynamo capcity issue.
@@CompleteCoding OK. By chance would you know any good study video/material for someone going for the AWS solutions architect and the developer's associate exams?
@@renejacques8288 Go to Udemy and search for the exam you're taking. There are some with thousands of 5* reviews.
The ones I've done previously will be out of date now
Thanks a lot Sir
Most welcome
How to send array of json objects in post method
First check out my video on creating a POST endpoint ruclips.net/video/AguTaMQGACE/видео.html
Using that video, you would just need to change the logic in your Lambda. The event body will now be an array of objects so you can do something like:
const arrayOfNewUsers = JSON.parse(event.body)
const promiseArray = arrayOfNewUsers.map(async (user) => {
const newUser = await Dynamo.write(user, tableName)
return newUser
});
const users = await Promise.all(promiseArray);
If you pass three objects in the array, it will 'map' over them and each one will write to dynamo. You end up with three promises so you just use 'Promise.all' to make sure they all succeed.
is it possible to create this API for using offline (local) with also serverless and dynamodb offline?
Definitely. Here's a video on it
ruclips.net/video/ul_85jfM0oo/видео.html
@@CompleteCoding thanks for that bro, excellent content. Keep going!
is there a way to fetch the whole table?
You could use a Scan. This is not advised though as it isn't a very optimised request. You also only get back the first 1MB of data, and then you'd have to subsequently make requests until you've got the whole table.
The other way is to query each index in your table.
Either way it's not a process that you want to be doing. Maybe you could redesign your app so you don't have to read a whole table at once.
@@CompleteCoding thank you for the scan option..i also figured out that scan was an option to fetch the whole data contents- if I need to plot in a table..but if i need to plot entity wise or date wise i'll use query thanks for the tips
I get a response to 502 bad gateway for several times trying. I don't know what happened. I sure the code is the same with this tutorial. Somebody can help me? thanks.
If you go into the lambda in the AWS console and the 'monitoring' tab. Have a look at the recent invocations. You should be able to see anything that is console.log() in the code. This should point you in the right direction
I want the same code for get method but in python
I've not got any Python code I can share at the moment but this page has a lot of good starter Python code
docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.Python.03.html
{"message": "Internal server error"} i get this error
If you look in the lambda logs then you should find out why the function has errored
I was getting similar error. Looked up Lambda logs and found out my Dynamo.js function was failing because of a typo in AWS.DynamoDB.DocumentClient();