Search code examples
amazon-web-servicesamazon-dynamodb

DynamoDB - BatchGetItem - The provided key element does not match the schema


I am getting a "The provided key element does not match the schema" and I don't quite understand why.

I am using command the command below. I am trying to use a wildcard (*), but even when I use a specific id, it does not work.

aws dynamodb batch-get-item --request-items "{\"my-table\":{\"Keys\":[{\"Id\":{\"S\":\"*\"}}],\"ConsistentRead\":true,\"ProjectionExpression\":\"Id, TimeToLive\"}}"

The id column of the table is called 'Id'.

Looking at the doc, I don't see what I am doing wrong.

Also, just to let you guys know, my goal is to delete every row where TimeToLive is null/empty.


Solution

  • You can't use a Wildcard with BatchGetItem, you must use the full primary key for each item.

    What you need to use is Scan with a FilterExpression.

    aws dynamodb scan \
    --table-name my-table \
    --filter-expression "attribute_not_exists('ttl')" \
    --projection-expression "Id"