こちらで作成したテーブルに対しての操作の話です。
DynamoDB に boto3 で接続 (ハッシュキー、レンジキーを使う)
get-item で次のようなエラーが出ました。
$ aws dynamodb get-item --table-name tbl_iot --endpoint-url http://localhost:8000 --key '{ "id_device": {"S": "ras003" } }'
An error occurred (ValidationException) when calling the GetItem operation: The number of conditions on the keys is invalid
delete-item でも次のようなエラーが出ます。
$ aws dynamodb delete-item --table-name tbl_iot --endpoint-url http://localhost:8000 --key '{"id_device": {"S": "ras0003"}}'
An error occurred (ValidationException) when calling the DeleteItem operation: The number of conditions on the keys is invalid
ハッシュキー、レンジキーを使っているテーブルに対して、get-item, delete-item で ハッシュキー と レンジキーを 指定しなかったので発生したエラーです。
次のスクリプトならば、エラーは出ません。
go_get.sh
ARGS="--table-name tbl_iot --endpoint-url http://localhost:8000"
#
aws dynamodb get-item $ARGS \
--key '{"id_device": {"S": "ras0003"},"timestamp": { "S": "20180122082100" }}'
go_delete.sh
ARGS="--table-name tbl_iot --endpoint-url http://localhost:8000"
#
aws dynamodb delete-item $ARGS \
--key '{"id_device": {"S": "ras0003"},"timestamp": { "S": "20180122082200" }}'