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 created

An 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 new LocalSecondaryIndexes entry 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

  1. Create a new table with the LSI defined up front, then migrate data (scan-and-write, or an on-demand export/import).
  2. 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", ...}}]'
  3. Plan LSIs during modeling — decide alternate sort keys before the table exists, since they can't be retrofitted.

Console 없이 DynamoDB 작업하기

DynoTable은 DynamoDB를 위한 빠른 데스크톱 클라이언트입니다 — 테이블을 탐색하고, SQL 스타일 쿼리를 실행하고, 항목을 로컬에서 편집하세요.