I am trying to delete an item in a dynamodb table. Even if I provide the correct id, the command rejects it:
aws dynamodb delete-item --table-name my-table --key 9cjmB5rjbqYWJ6USMf9OEV13Kyoxs6VAN8xl9Sutzdl7gTpaxX2UgA==
Here's the error I get:
Error parsing parameter '--key': Expected: ',', received: '=' for input:
9cjmB5rjbqYWJ6USMf9OEV13Kyoxs6VAN8xl9Sutzdl7gTpaxX2UgA==
Adding double quotes around the key does not work. Backslashes before '=' does not do it either.
To delete an item from a DynamoDB table using the AWS CLI, I believe you need to format the --key
parameter as a JSON object.
Assuming the primary key of your table is called id
and it's a string type, your command should look something like this:
aws dynamodb delete-item \
--table-name my-table \
--key '{"id": {"S": "9cjmB5rjbqYWJ6USMf9OEV13Kyoxs6VAN8xl9Sutzdl7gTpaxX2UgA=="}}'
Just replace id
with the name of your table's primary key, and ensure the value and type ("S"
for string) are correct for your specific item. Give that a go and if it doesn’t work, we can look further.