In this lab, we will explore the read and write processes available for a DynamoDB table. In the lab instructions, you will find a scenario that provides some sample data that will need to be entered into a DynamoDB table, as well as several ways to retrieve the data from the DynamoDB table. In the solution videos, we will walk through reading from and writing to a DynamoDB table with the AWS Management Console, AWS CLI, and the Python Boto3 SDK.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Convert Provided CSV Data to DynamoDB-JSON
Convert the following provided CSV records:
Monitor Lizard,319,Duncan,Moss,4,Male,Null,Spiky Iguana,146,Jessica,Seaweed,10,Female,Null,Rough Iguana,159,Paul,Basil,3,Male,Null,Rough Chinchilla,631,Shadam,Stone,2,Male,Soft,Null Chinchilla,805,Irulan,Snow,1,Female,Soft,Null Red-tailed Boa,3,Vladimir,Abalone/Brick,18,Male,Null,Smooth Red-tailed Boa,9,Feyd-Rautha,Ash/Caramel,8,Male,Null,Smooth
To make them DynamoDB-JSON syntax as shown below:
{ "age": { "N": "4" }, "color": { "S": "Moss" }, "gender": { "S": "Male" }, "name": { "S": "Duncan" }, "pet_id": { "N": "319" }, "pet_species": { "S": "Monitor Lizard" }, "scale_texture": { "S": "Spiky" } }
- Add Records to `PetInventory` Table
Add the records to the
PetInventory
DynamoDB table using thePutItem
API call.This can be accomplished in one of the following ways:
- With the Create Item button in the AWS Management Console
- With the
aws dynamodb put-item
command in the AWS CLI - With the Boto3 SDK
put_item
method for the Client or Table interfaces
- Update All Records in the Table
Update the records in the table with the
UpdateItem
API call to add the missing pet_available attribute.This can be done in one of the following ways:
- In the AWS Management Console by editing the item
- In the AWS CLI with the
aws dynamodb update-item
command - With the Boto3 SDK using the
update_item
method
- Confirm Data Has Been Added and Updated Successfully
Manually confirm all data has been updated in the table correctly.
This can be done in one of the following ways:
- In the AWS Management Console, review the table output in the interface.
- In the AWS CLI, run
aws dynamodb scan --table-name PetInventory
.
- Final Confirmation with Provided Scripts
Run the
confirmlab.py
andconfirmlabfinal.py
scripts:python3 confirmlab.py python3 confirmlabfinal.py
Ensure the output matches the output provided in the lab information.