I created a table 'user_info' in DynamoDB with one primary hash key 'user_id'(String), no range key. Then I created 2 AWS lambda functions to insert and query the items. I can insert items into the table, but when I query the table, it returns:
ValidationException: The provided key element does not match the schema.
My query function :
var params = {
Key: {
user_id:{
S: "[email protected]"
}
},
TableName: 'user_info',
ProjectionExpression: 'password'
};
dynamodb.getItem(params,
function(err, data) {
if (err) {
console.log("get item err." + err);
context.done('error','getting item from dynamodb failed: '+err);
}
else {
console.log('great success: '+JSON.stringify(data, null, ' '));
context.succeed('created user ' + event.user_id + ' successfully.');
}
});
I keep getting this exception:
ValidationException: The provided key element does not match the schema
Since
1) I have only one hash primary key.
2)user_id is defined as String. I really don't know why there is a mismatch error.