1
votes

I got a table in dynamodb

aws dynamodb describe-table --table-name work

{
"Table": {
    "TableArn": "../work",
    "AttributeDefinitions": [
        {
            "AttributeName": "id",
            "AttributeType": "S"
        }
    ],
    "ProvisionedThroughput": {
        "NumberOfDecreasesToday": 0,
        "WriteCapacityUnits": 5,
        "ReadCapacityUnits": 5
    },
    "TableSizeBytes": 0,
    "TableName": "work",
    "TableStatus": "ACTIVE",
    "KeySchema": [
        {
            "KeyType": "HASH",
            "AttributeName": "id"
        }
    ],
    "ItemCount": 0,
    "CreationDateTime": 1505847222.951
}

and my data was like

id(P.K) location

1 location1

2 location1

3 location2

And in my key.json

{
"location": {"S": "location1"}

}

And when I

aws dynamodb delete-item --table-name work --key file://key.json

An error occurred (ValidationException) when calling the DeleteItem operation: The provided key element does not match the schema

1

1 Answers

1
votes
{
    "id": {"S": "location1"}
}

You key.json is in wrong format.

Check the documentation,

https://docs.aws.amazon.com/cli/latest/reference/dynamodb/delete-item.html