Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error creating index on DynamoDB table: AttributeDefinitions is not specified

I'm trying to add a global secondary index to an existing DynamoDB table using the AWS command line interface.

As per the documentation, I'm using this update-table command:

aws dynamodb update-table --table-name messages --global-secondary-index-updates file://input.json

and my input.json file has the definition of the index:

[
  {
    "Create": {
      "IndexName": "FeedIndex",
      "KeySchema": [
        {
          "AttributeName": "feed",
          "KeyType": "HASH"
        },
        {
          "AttributeName": "status",
          "KeyType": "RANGE"
        }
      ],
      "Projection": {
        "ProjectionType": "INCLUDE",
        "NonKeyAttributes": ["message"]
      },
      "ProvisionedThroughput": {
        "ReadCapacityUnits": 5,
        "WriteCapacityUnits": 5
      }
    }
  }
]

When I run the command, I get this error:

An error occurred (ValidationException) when calling the UpdateTable operation: One or more parameter values were invalid: AttributeDefinitions is not specified for index: FeedIndex

Why would I get this error? It seems to me from the documentation that I've specified all I need to for adding the index. AttributeDefinitions gets specified when creating a table initially; I would have thought that these definitions would not be needed for adding an index to an existing table.

like image 204
osullic Avatar asked Oct 22 '25 16:10

osullic


1 Answers

The attribute-definitions was missed. You need to define the attributes that are part of KeySchema.

aws dynamodb update-table --table-name messages --attribute-definitions AttributeName=feed,AttributeType=S AttributeName=status,AttributeType=S --global-secondary-index-updates file://input.json
like image 177
notionquest Avatar answered Oct 24 '25 08:10

notionquest



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!