DynamoDB – How to Search by Attribute

dynamodb

I inherited a site that uses DynamoDB for its database, which I know nothing about unfortunately, and I'm trying to change a user's email for them. There appears to be a users table in DynamoDB, but I don't know the user's id, only their username and current email, so at this point, I am just trying to find the record before updating it. When I attempt to scan for these values in the web interface, I get no results; it just keeps searching. If I scan in the web interface for an email address which I know exists, I also get no results.

Using these placeholder values,

Username: example
Email: example@example.com

I have tried a few commands using AWS CLI, but I get various errors:

aws dynamodb get-item --table-name users --key '{"Username": {"S": "example"}}'

This yields this error:

Unknown options: example}}', {S:

I have also tried this:

aws dynamodb query --table-name users --key-condition-expression "Username = :v1" --expression-attribute-values "{ \":v1\" : { \"S\" : \"example\" } }"

This yields this error:

An error occurred (ValidationException) when calling the Query operation: Query condition missed key schema element: id

I have also tried printing out all users, but it appears to fail for anything but the smallest tables:

aws dynamodb scan --table-name users

This yields this error:

An error occurred (ProvisionedThroughputExceededException) when calling the Scan operation (reached max retries: 2): The level of configured provisioned throughput for the table was exceeded. Consider increasing your provisioning level with the UpdateTable API.

Not sure what to do at this point. Any advice?

Best Answer

I contacted AWS support, and they said two things:

  1. The read/write capacity of the table needed to be changed from "provisioned" to "on-demand".

  2. Scan is definitely the command to use here, not query; query requires the id, scan does not.

    aws dynamodb scan --table-name users --filter-expression "Username = :v1" 
        --expression-attribute-values "{ \":v1\" : { \"S\" : \"example\" } }"