Richard210363
Richard210363

Reputation: 8406

Is DynamoDB's C# API DescribeTableResponse returning incorrect data?

I have a simple DynamoDB table with a Hash Key and an Index

Table:

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

Answers (1)

Jason Wadsworth
Jason Wadsworth

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

Related Questions