Skip to content

Instantly share code, notes, and snippets.

@cerberodev
Last active November 19, 2020 17:46
Show Gist options
  • Save cerberodev/2e8606b6a390732385546db285d69005 to your computer and use it in GitHub Desktop.
Save cerberodev/2e8606b6a390732385546db285d69005 to your computer and use it in GitHub Desktop.
aws dynamodb create-table \
--table-name Hero \
--attribute-definitions \
AttributeName=ID,AttributeType=S \
AttributeName=Name,AttributeType=S \
--key-schema AttributeName=ID,KeyType=HASH AttributeName=Name,KeyType=RANGE \
--provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1
aws dynamodb put-item \
--table-name Hero \
--item \
'{"ID": {"S": "4"}, "Name": {"S": "SpiderMan"}, "UrlImage": {"S": ""}}' \
--return-consumed-capacity TOTAL
aws dynamodb put-item \
--table-name Canciones \
--item '{ \
"Artist": {"S": "Acme Band"}, \
"SongTitle": {"S": "Happy Day"}, \
"AlbumTitle": {"S": "Songs About Life"} }' \
--return-consumed-capacity TOTAL
aws dynamodb query --table-name Canciones --key-conditions file://key-conditions.json
aws dynamodb query --table-name Hero --key-conditions file://key-conditions.json
aws dynamodb create-table --table-name Hero --attribute-definitions AttributeName=ID,AttributeType=S AttributeName=Name,AttributeType=S --key-schema AttributeName=ID,KeyType=HASH AttributeName=Name,KeyType=RANGE --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=10
aws dynamodb put-item --table-name Hero --item '{"ID": {"S": "2"}, "Name": {"S": "SpiderMan"}, "UrlImage": {"S": ""}}' --return-consumed-capacity TOTAL
aws dynamodb put-item --table-name Hero --item "{\"ID\":{\"S\":\"6\"},\"Name\":{\"S\":\"Capitan America\"}}"
aws dynamodb put-item --table-name Hero --item "{\"ID\":{\"S\":\"30\"},\"Name\":{\"S\":\"Capitan Americá\"}}"
aws dynamodb put-item --table-name Hero --item file://heroes.json --return-consumed-capacity TOTAL
@sixtoromero
Copy link

JSON para insertar multiples filas

{
"Paises": [
{
"PutRequest": {
"Item": {
"ID": {
"S": "1"
},
"Name": {
"S": "Colombia"
},
"Symbol": {
"S": "CO"
}
}
}
},
{
"PutRequest": {
"Item": {
"ID": {
"S": "2"
},
"Name": {
"S": "Peru"
},
"Symbol": {
"S": "PE"
}
}
}
},
{
"PutRequest": {
"Item": {
"ID": {
"S": "3"
},
"Name": {
"S": "Venezuela"
},
"Symbol": {
"S": "VE"
}
}
}
}
]
}

comando
aws dynamodb batch-write-item --region us-west-2 --request-items file://paises.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment