I am creating a table and GSI in DynamoDB, using these parameters, as per the documentation:
configId is the primary key of the table, and I am using the publisherId as the primary key for the GSI. (I've removed some unnecessary configuration parameters for brevity)
var params = {
TableName: 'Configs',
KeySchema: [
{
AttributeName: 'configId',
KeyType: 'HASH',
}
],
AttributeDefinitions: [
{
AttributeName: 'configId',
AttributeType: 'S',
},
{
AttributeName: 'publisherId',
AttributeType: 'S',
}
],
GlobalSecondaryIndexes: [
{
IndexName: 'publisher_index',
KeySchema: [
{
AttributeName: 'publisherId',
KeyType: 'HASH',
}
]
}
]
};
I am querying this table using this:
{ TableName: 'Configs',
IndexName: 'publisher_index',
KeyConditionExpression: 'publisherId = :pub_id',
ExpressionAttributeValues: { ':pub_id': { S: '700' } } }
but I keep getting the error:
"ValidationException: One or more parameter values were invalid: Condition parameter type does not match schema type"
In the docs it specifies that the primary KeyType can either be HASH or RANGE, and that you set the AttributeType in the AttributeDefinitions field. I am sending the publisherId as String, not sure what I am missing here.
Is the issue in the way I am creating the table, or the way I am querying? Thanks