DynamoDB API Filtered Scan Returns No Results

So, I'm running a validation of a DynamoDB table with ~ 500 records using AWS CLI via Powershell because AWS Powershell Tools doesn't support DDB query / scan operations. I can run the command without filters and get all my items:

& aws dynamodb scan --table-name "$table_name" --projection-expression "$item_key"

      

This returns all 500+ $ item_key values.

The problem occurs 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 count of 0 and no items, although there are multiple values ​​in the table that match $ item_value.

What am I missing / doing wrong here?

+3


source to share


1 answer


Suppose $item_value

it expands to here foobar

. What this filter expression looks for are elements, attributes, item_key_2

and foobar

have the same meaning:

{
  "item_key": "...",
  "item_key_2": "It a match!",
  "foobar": "It a match!"
}

      

To compare item_key_2 with 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`"}}"

      

: (

+1


source







All Articles