Invalid type for AWS DynamoDB put-item via CLI (unicode v. dict)
you need to add the type information (I assume String here)
aws dynamodb put-item --table-name my_table --item '{ "id": {"S": "1" } }'
We cannot provide a plain JSON schema as an input to the dynamodb put-item
command. We need to provide the attribute(s) data type along with its value.
But if you have a complex JSON schema and you are new to the aws dynamodb cli
commands then it becomes really tedious for you to prepare your input JSON file.
But we have an easy solution as well, please follow these steps:
- Prepare a sample JSON schema which you want to insert into your dynamodb table.
- Login to AWS Console, go to DynamoDB -> Tables -> , and from the top tabs chose
Items
, it will show you the data if any already. - Now click on the
Create Item
, it will open a new window and from there choose the optionText
instead ofTree
. Paste your sample JSON schema there and save this item. - Now Select that record and from
Actions
choose the optionExport to .csv
. This csv file contains your JSON attribute name (keys), their corresponding values along with their data type. - Now most of the work has been done for you and you can easily construct the input JSON file for your
dynamodb put-item
command.