hashicorp / terraform-provider-awscc

Terraform AWS Cloud Control provider
https://registry.terraform.io/providers/hashicorp/awscc/latest/docs
Mozilla Public License 2.0
261 stars 120 forks source link

awscc_dynamodb_table: key_schema and attribute_definitions expected to match in number of attributes #1680

Closed quixoticmonk closed 4 months ago

quixoticmonk commented 6 months ago

Community Note

Terraform CLI and Terraform AWS Cloud Control Provider Version

Affected Resource(s)

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.


resource "awscc_dynamodb_table" "main" {
  table_name = "dynamodb_table_name"
  key_schema = jsonencode([{
    AttributeName = "UserId"
    KeyType       = "HASH"
  }])

  attribute_definitions = [{
    attribute_name = "UserId"
    attribute_type = "S"
    },
    {
    attribute_name = "Test"
    attribute_type = "S"
    },
    ]

  billing_mode = "PROVISIONED"
  provisioned_throughput = {
    read_capacity_units  = 20
    write_capacity_units = 20
  }
  deletion_protection_enabled = true
  table_class = "STANDARD"
}

Debug Output

Panic Output

Expected Behavior

The table should be provisioned.

Actual Behavior

The apply step fails with the schema validation error below.

│ Waiting for Cloud Control API service CreateResource operation completion returned: waiter state transitioned to FAILED. StatusMessage: Number of attributes in KeySchema does not exactly
│ match number of attributes defined in AttributeDefinitions. ErrorCode: InvalidRequest

Steps to Reproduce

  1. terraform apply

Important Factoids

Opening this for visibility based on https://github.com/hashicorp/terraform-provider-awscc/issues/951#issuecomment-2093507074

References

tgeijg commented 6 months ago

Not unexpectedly, this issue is also present on the awscc_dynamodb_global_table resource

quixoticmonk commented 5 months ago

Opened an internal service ticket for this.

quixoticmonk commented 4 months ago

This is the current behavior across APIs in the DynamoDB side. The Key schema union for the table and a possible index should match the Attribute definitions.