hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io
Other
42.77k stars 9.56k forks source link

Changing a global secondary index attribute type fails to take effect #30446

Closed sambonator closed 2 years ago

sambonator commented 2 years ago

Terraform Version

Terraform v1.1.4
on windows_amd64

Terraform Configuration Files

resource "aws_dynamodb_table" "test-dynamodb-table" {
  name           = "TestDynamo"
  billing_mode   = "PROVISIONED"
  read_capacity  = 3
  write_capacity = 1
  hash_key       = "ProgHash"
  #range_key      = "location"

  attribute {
    name = "ProgHash"
    type = "S"
  }
  attribute {
    name = "ProgName"
    type = "S"
  }
  attribute {
    name = "ProgVersion"
    type = "S"
  }
  global_secondary_index {
    name               = "ProgName"
    hash_key           = "ProgName"
    range_key          = "ProgVersion"
    read_capacity  = 3
    write_capacity = 1
    projection_type    = "ALL"
  }
}

Debug Output

terraform apply aws_dynamodb_table.test-dynamodb-table: Refreshing state... [id=TestDynamo]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Expected Behavior

When the attribute of ProgVersion is changed from S to N, we expect the index to be revised from using String to Number. e,g.: attribute { name = "ProgVersion" type = "S" }

Change the above to: attribute { name = "ProgVersion" type = "N" }

Actual Behavior

Terraform doesn't detect the updated attribute for the index. Responds with : Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Steps to Reproduce

  1. terraform init
  2. terraform appy
  3. Change attribute type of ProgVersion from S to N.
  4. terraform appy

No change is made to the database, as terraform fails to detect the change.

Additional Context

References

jbardin commented 2 years ago

Hello,

This appears to be an issue or question with the AWS provider, not with Terraform itself. You can see existing issues and file a new one in their repository here: https://github.com/hashicorp/terraform-provider-aws/issues. If you have questions about Terraform or the AWS provider, it's better to use the community forum where there are more people ready to help. The GitHub issues here are monitored only by a few core maintainers.

Thanks!

github-actions[bot] commented 2 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.