-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trigger destructive update of resource_aws_dynamodb_table_item if range_key has changed #3821
Trigger destructive update of resource_aws_dynamodb_table_item if range_key has changed #3821
Conversation
Example case:
hash_key is kept static in the example above - that may not be very good design but encountered in real-life situation when terraforming configuration for https://github.com/aws-samples/aws-lambda-fanout/ When the value of items changes from ["first", "second", "third"] to ["first", "third"] the apply phase fails:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM -- thanks for this fix! 🚀
Previously:
make testacc TEST=./aws TESTARGS='-run=TestAccAWSDynamoDbTableItem_updateWithRangeKey'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSDynamoDbTableItem_updateWithRangeKey -timeout 120m
=== RUN TestAccAWSDynamoDbTableItem_updateWithRangeKey
--- FAIL: TestAccAWSDynamoDbTableItem_updateWithRangeKey (30.72s)
testing.go:518: Step 1 error: Error applying: 1 error(s) occurred:
* aws_dynamodb_table_item.test: 1 error(s) occurred:
* aws_dynamodb_table_item.test: ValidationException: One or more parameter values were invalid: Cannot update attribute rangeKey. This attribute is part of the key
status code: 400, request id: L1P9N1I61KTNJ6SI04UND6PKIJVV4KQNSO5AEMVJF66Q9ASUAAJG
FAIL
FAIL github.com/terraform-providers/terraform-provider-aws/aws 30.771s
make: *** [testacc] Error 1
Now:
5 tests passed (all tests)
=== RUN TestAccAWSDynamoDbTableItem_withMultipleItems
--- PASS: TestAccAWSDynamoDbTableItem_withMultipleItems (15.58s)
=== RUN TestAccAWSDynamoDbTableItem_basic
--- PASS: TestAccAWSDynamoDbTableItem_basic (16.95s)
=== RUN TestAccAWSDynamoDbTableItem_updateWithRangeKey
--- PASS: TestAccAWSDynamoDbTableItem_updateWithRangeKey (21.93s)
=== RUN TestAccAWSDynamoDbTableItem_update
--- PASS: TestAccAWSDynamoDbTableItem_update (26.87s)
=== RUN TestAccAWSDynamoDbTableItem_rangeKey
--- PASS: TestAccAWSDynamoDbTableItem_rangeKey (52.71s)
This has been released in version 1.14.1 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Version 1.11 of terraform-provider-aws generates invalid parameters for DynamoDB changes when aws_dynamodb_table_item range_key has changed due to attempting update in-place. This PR changes the provider behaviour to recreate such resources instead. This is useful especially in cases where DynamoDB table uses a composite key, items are created from lists and items in middle of the list are removed.