I created one item in my dynamodb and then my nodejs lambda function will keep updating access_token value inside this item. Below is the schema
{
"service": {
"S": "perform"
},
"access_token": {
"S": "xxxxxxxxxx"
}
}
Below are the dynamodb parameters that I will send to dynamodb update function
{
"TableName": "Access-Token",
"Key": {
"service": "perform"
},
"UpdateExpression": "set access_token = :token",
"ExpressionAttributeValues": {
":token": "xxxxxxxxxxxx"
},
"ReturnValues": "UPDATED_NEW"
}
But when I run the lambda function i received below error. Need help and guide on this
ValidationException: The provided key element does not match the schema
CodePudding user response:
It is likely that you are trying to insert a record which does not have all the key elements.
If your primary key is a combination of the partition/hash key and range/sort key, you need to include both in your Key attribute in the update or put parameters.
Looks like the key service
is your Partition key and the key access_token
is your Sort key.
To do a update you need to send both keys:
"Key": {
"service": "perform",
"access_token": "token"
}
In this way, if try to update the access_token
you will not be able because the access_token
attribute is part of the key.
If you want to update the access_token
you will need to create another table without/or with a different sort key, and use the access_token
as atribute.