So I'm running a scan of a DynamoDB table with ~500 records using the AWS CLI through Powershell, because the AWS Powershell Tools don't support DDB query/scan operations. I can run the command with no filters and get all my items:
& aws dynamodb scan --table-name "$table_name" --projection-expression "$item_key"
This returns all 500+ values of $item_key.
Problem comes when I try to filter the scan:
& aws dynamodb scan --table-name "$table_name" --projection-expression "$item_key" --filter-expression "item_key_2 = `"$item_value`""
This returns a count of 0 and no items, even though there are several values in the table that match $item_value.
What am I missing/doing wrong here?
Let's assume $item_value
here expands to foobar
. What that filter expression is looking for is items whose item_key_2
and foobar
attributes have the same value:
{
"item_key": "...",
"item_key_2": "It's a match!",
"foobar": "It's a match!"
}
To compare item_key_2 against a literal value, you need to do:
aws dynamodb scan \
--table-name "$table_name" \
--filter-expression "item_key_2 = :value" \
--expression-attribute-values "{`":value`":{`"S`":`"$item_value`"}}"
:(
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.