In your case you need to use expression attribute names and expression attribute values. This is a very good practice in any DynamoDB query.
Please note that you'll also need to set a partition key (see #pk
and :pk
below).
aws dynamodb query \
--table-name TABLE_NAME \
--key-condition-expression "#pk = :pk AND #sk BETWEEN :a and :b" \
--expression-attribute-names '{"#sk": "sort_key", "#pk": "partition_key"}' \
--expression-attribute-values '{":a": {"S":"3456|67"}, ":b": {"S":"8968|67"}, ":pk":{"S":"partition_key_value"}}'
I didn't use this syntax for a while, there may me some small syntax error, but this is what you have to do in order to query with BETWEEN
.
See the last example about KeyConditions:
aws dynamodb query \
--table-name Music \
--key-condition-expression 'Artist = :a AND SongTitle BETWEEN :t1 AND :t2' \
--expression-attribute-values '{
":a": {"S": "No One You Know"},
":t1": {"S": "A"},
":t2": {"S": "M"}
}'