Reputation: 8406
I have a simple DynamoDB table with a Hash Key and an Index
Table:
Name: bank-statements
Hash Key: MTSTransactionID of type N
Index: StatementType-index of type S
When I do this:
DescribeTableResponse descResponse = _dynamoDbClient.DescribeTable(new DescribeTableRequest
{TableName = "bank-statements"});
tableDescription = descResponse.Table;
then,
Then I use the tableDescription to recreate the table by doing this:
CreateTableRequest createTableRequest = new CreateTableRequest
{
TableName = tableDescription.TableName,
AttributeDefinitions = tableDescription.AttributeDefinitions,
KeySchema = tableDescription.KeySchema,
ProvisionedThroughput = new ProvisionedThroughput
{
ReadCapacityUnits = tableDescription.ProvisionedThroughput.ReadCapacityUnits,
WriteCapacityUnits = tableDescription.ProvisionedThroughput.WriteCapacityUnits
}
};
CreateTableResponse response = _dynamoDbClient.CreateTable(createTableRequest);
However, this produces an error:
One or more parameter values were invalid: Number of attributes in KeySchema does not exactly match number of attributes defined in AttributeDefinitions
Which is true but means either
What can I do to use the DescribeTableResponse to recreate the table anew?
Upvotes: 0
Views: 85
Reputation: 8885
The issue is that you have a key that is used by your index but you aren't creating the index. That leaves you with an unused key.
Upvotes: 1