Skip to content

aws_dynamodb_table fails with Error: all indexes must match a defined attribute. Unmatched indexes: [""] #46606

@artms

Description

@artms

Terraform and AWS Provider Version

Terraform v1.10.5
on linux_amd64

AWS provider (working 6.28.0), failing 6.29.0+

Affected Resource(s) or Data Source(s)

  • aws_dynamodb_table

Expected Behavior

No failures/crash

Actual Behavior

Error: all indexes must match a defined attribute. Unmatched indexes: [""]

Relevant Error/Panic Output

│ Error: all indexes must match a defined attribute. Unmatched indexes: [""]

│   with aws_dynamodb_table.test,
│   on test.tf line 1, in resource "aws_dynamodb_table" "test":
│    1: resource "aws_dynamodb_table" "test" {


Error: Process completed with exit code 1.

Sample Terraform Configuration

Click to expand configuration
resource "aws_dynamodb_table" "test" {
  name         = "test"
  billing_mode = "PAY_PER_REQUEST"
  hash_key     = "hash"

  attribute {
    name = "hash"
    type = "S"
  }

  lifecycle {
    ignore_changes = [
      global_secondary_index,
      read_capacity,
      write_capacity,
    ]
  }

  dynamic "global_secondary_index" {
    for_each = ["test"]
    content {
      hash_key        = "hash"
      name            = "name"
      projection_type = "ALL"
    }
  }
}

Steps to Reproduce

  1. Apply configuration to create AWS DynamoDB table
  2. Rerun plan step which will fail immediately with error:
Error: all indexes must match a defined attribute. Unmatched indexes: [""]

Only affects when global_secondary_index is in lifecycle ignore changes section. It is not affecting plan when changes are not ignored.

Debug Logging

range_key becomes empty string and afterwards it fails the check.

A regression caused by commit

GenAI / LLM Assisted Development

Not used

Important Facts and References

A regression caused by commit

Would you like to implement a fix?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAddresses a defect in current functionality.needs-triageWaiting for first response or review from a maintainer.service/dynamodbIssues and PRs that pertain to the dynamodb service.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions