Skip to content

Instantly share code, notes, and snippets.

@kevinhooke
Last active March 10, 2021 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinhooke/b3ef76e5f4a921bf98670d8991cd28b3 to your computer and use it in GitHub Desktop.
Save kevinhooke/b3ef76e5f4a921bf98670d8991cd28b3 to your computer and use it in GitHub Desktop.
aws cli dynamodb put-item and get item
aws --endpoint-url=http://localhost:4566 dynamodb put-item --table-name exampletable --item '{
"LastName" : { "S" : "test1" }
}' \
--return-consumed-capacity TOTAL
#query table with only a hash key
aws --endpoint-url=http://localhost:4566 dynamodb query --table-name exampletable \
--key-condition-expression "LastName = :v1" \
--expression-attribute-values '{
":v1" : {"S": "test1"}
}'
#query table with only a hash key using expression parameter names
aws --endpoint-url=http://localhost:4566 dynamodb query --table-name exampletable \
--key-condition-expression ":key1 = :v1" \
--expression-attribute-names '{ ":key1" : "LastName" }' \
--expression-attribute-values '{
":v1" : {"S": "test1"}
}'
#query a table with a hash and range key
aws --endpoint-url=http://localhost:4566 dynamodb query --table-name exampletable2 \
--key-condition-expression "LastName = :v1 AND DOB BETWEEN :v2 AND :v3" \
--expression-attribute-values '{
":v1" : {"S": "test1"},
":v2" : {"S": "1900-01-01"},
":v3" : {"S": "1910-01-01"},
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment