I am trying to create a table on dynamodb trough their aws-sdk on nodejs. Below is the parameter I am passing on dynamodb.createTable:
{
TableName: 'new_table',
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1
},
KeySchema: [
{AttributeName: 'primary_key', KeyType: 'HASH'}
],
AttributeDefinitions: [
{AttributeName: 'primary_key', AttributeType: 'S'},
{AttributeName: 'some_attribute', AttributeType: 'S'}
]
}
This returns
ValidationException: One or more parameter values were invalid: Number of attributes in KeySchema does not exactly match number of attributes defined in AttributeDefinitions
I have fixed this by adding 'some_attribute' on 'KeySchema' but what I want is a 'hash' only table with no 'range'.
Solved: When creating a table, you only need to specify the KeySchema attributes and not all attributes that you will be putting on the table. So in my case I just need to specify the 'primary_key'
{
TableName: 'new_table',
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1
},
KeySchema: [
{AttributeName: 'primary_key', KeyType: 'HASH'}
],
AttributeDefinitions: [
{AttributeName: 'primary_key', AttributeType: 'S'},
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With