Local secondary indexes must be specified at table creation
TL;DR — A local secondary index (LSI) can only be created at the moment its table is created; it cannot be added, changed, or removed afterward. UpdateTable has no operation for LSIs, so any attempt to add one to a live table fails validation. To get a new LSI you must create a new table (with the LSI) and migrate the data — or use a global secondary index (GSI), which can be added online.
What it means
ValidationException: One or more parameter values were invalid: Local secondary
indexes can only be created when a table is createdAn LSI shares its partition key with the base table and adds an alternate sort key; DynamoDB co-locates it with the item's partition at write time. Because of that physical coupling, an LSI must exist from the table's first write — UpdateTable supports adding/removing GSIs but has no LSI update path. This is an HTTP 400 ValidationException and it is not retryable: the operation simply isn't supported on an existing table.
Why it happens
- Adding an LSI to a live table — calling
UpdateTable(or editing a CloudFormation/Terraform template) to introduce a newLocalSecondaryIndexesentry on a table that already exists. - Changing an existing LSI — its key schema or projection is fixed at creation; edits are rejected.
- An IaC diff that recreates vs. updates — the tool tries to update-in-place an LSI change that DynamoDB only allows at create time.
How to fix it
- Create a new table with the LSI defined up front, then migrate data (scan-and-write, or an on-demand export/import).
- Use a GSI instead if the access pattern allows it — GSIs can be added to an existing table online and don't require the same partition key:
aws dynamodb update-table --table-name <Table> \ --attribute-definitions AttributeName=gsi_sk,AttributeType=S \ --global-secondary-index-updates '[{"Create":{"IndexName":"gsi1", ...}}]' - Plan LSIs during modeling — decide alternate sort keys before the table exists, since they can't be retrofitted.
Related errors
- Attempting to modify a GSI that is being created — a GSI change blocked while the index builds.
- Requested resource not found / index not found — querying an index name that doesn't exist.
- ValidationException (overview)