-
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
dynamodb_table_item
create
: use ConditionExpression
#27517
Conversation
- per [AWS' documentation](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.Expected.html) `Expected` is a legacy parameter and should no longer be used - should fix #26080, or at least be more predictable, while maintaining the same behavior for tables without composite keys. It seems like `Expected` is only checking that the hash key does not exist whereas this `ConditionExpression` will check whether an item with the same hash key _and_ range key does not exist - [this blog post](https://www.alexdebrie.com/posts/dynamodb-condition-expressions/) explains how this `ConditionExpression` works, essentially the condition will always be compared against a single item and so it is sufficient to just check for the existence of the hash key
Community NoteVoting for Prioritization
For Submitters
|
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.
Welcome @milescrabill 👋
It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTOR guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.
Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.
Thanks again, and welcome to the community! 😃
…stAccDynamoDBTableItem_withDuplicateItemsDifferentRangeKey'.
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 🚀.
% make testacc TESTARGS='-run=TestAccDynamoDBTableItem_' PKG=dynamodb ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/dynamodb/... -v -count 1 -parallel 2 -run=TestAccDynamoDBTableItem_ -timeout 180m
=== RUN TestAccDynamoDBTableItem_basic
=== PAUSE TestAccDynamoDBTableItem_basic
=== RUN TestAccDynamoDBTableItem_rangeKey
=== PAUSE TestAccDynamoDBTableItem_rangeKey
=== RUN TestAccDynamoDBTableItem_withMultipleItems
=== PAUSE TestAccDynamoDBTableItem_withMultipleItems
=== RUN TestAccDynamoDBTableItem_withDuplicateItemsSameRangeKey
=== PAUSE TestAccDynamoDBTableItem_withDuplicateItemsSameRangeKey
=== RUN TestAccDynamoDBTableItem_withDuplicateItemsDifferentRangeKey
=== PAUSE TestAccDynamoDBTableItem_withDuplicateItemsDifferentRangeKey
=== RUN TestAccDynamoDBTableItem_wonkyItems
=== PAUSE TestAccDynamoDBTableItem_wonkyItems
=== RUN TestAccDynamoDBTableItem_update
=== PAUSE TestAccDynamoDBTableItem_update
=== RUN TestAccDynamoDBTableItem_updateWithRangeKey
=== PAUSE TestAccDynamoDBTableItem_updateWithRangeKey
=== RUN TestAccDynamoDBTableItem_disappears
=== PAUSE TestAccDynamoDBTableItem_disappears
=== CONT TestAccDynamoDBTableItem_basic
=== CONT TestAccDynamoDBTableItem_wonkyItems
--- PASS: TestAccDynamoDBTableItem_basic (25.47s)
=== CONT TestAccDynamoDBTableItem_withDuplicateItemsSameRangeKey
--- PASS: TestAccDynamoDBTableItem_wonkyItems (28.14s)
=== CONT TestAccDynamoDBTableItem_withDuplicateItemsDifferentRangeKey
--- PASS: TestAccDynamoDBTableItem_withDuplicateItemsSameRangeKey (17.61s)
=== CONT TestAccDynamoDBTableItem_withMultipleItems
--- PASS: TestAccDynamoDBTableItem_withDuplicateItemsDifferentRangeKey (26.25s)
=== CONT TestAccDynamoDBTableItem_rangeKey
--- PASS: TestAccDynamoDBTableItem_withMultipleItems (26.49s)
=== CONT TestAccDynamoDBTableItem_updateWithRangeKey
--- PASS: TestAccDynamoDBTableItem_rangeKey (26.05s)
=== CONT TestAccDynamoDBTableItem_disappears
--- PASS: TestAccDynamoDBTableItem_disappears (27.43s)
=== CONT TestAccDynamoDBTableItem_update
--- PASS: TestAccDynamoDBTableItem_updateWithRangeKey (40.38s)
--- PASS: TestAccDynamoDBTableItem_update (38.15s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/dynamodb 150.180s
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.
Looks good to me 🎉
% make testacc TESTARGS='-run=TestAccDynamoDBTableItem_' PKG=dynamodb ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/dynamodb/... -v -count 1 -parallel 2 -run=TestAccDynamoDBTableItem_ -timeout 180m
go: downloading github.com/aws/aws-sdk-go-v2/service/auditmanager v1.20.11
go: downloading github.com/aws/aws-sdk-go-v2/service/ivschat v1.0.21
go: downloading github.com/aws/aws-sdk-go-v2/service/scheduler v1.0.1
go: downloading github.com/aws/aws-sdk-go-v2/service/ssm v1.32.1
=== RUN TestAccDynamoDBTableItem_basic
=== PAUSE TestAccDynamoDBTableItem_basic
=== RUN TestAccDynamoDBTableItem_rangeKey
=== PAUSE TestAccDynamoDBTableItem_rangeKey
=== RUN TestAccDynamoDBTableItem_withMultipleItems
=== PAUSE TestAccDynamoDBTableItem_withMultipleItems
=== RUN TestAccDynamoDBTableItem_withDuplicateItemsSameRangeKey
=== PAUSE TestAccDynamoDBTableItem_withDuplicateItemsSameRangeKey
=== RUN TestAccDynamoDBTableItem_withDuplicateItemsDifferentRangeKey
=== PAUSE TestAccDynamoDBTableItem_withDuplicateItemsDifferentRangeKey
=== RUN TestAccDynamoDBTableItem_wonkyItems
=== PAUSE TestAccDynamoDBTableItem_wonkyItems
=== RUN TestAccDynamoDBTableItem_update
=== PAUSE TestAccDynamoDBTableItem_update
=== RUN TestAccDynamoDBTableItem_updateWithRangeKey
=== PAUSE TestAccDynamoDBTableItem_updateWithRangeKey
=== RUN TestAccDynamoDBTableItem_disappears
=== PAUSE TestAccDynamoDBTableItem_disappears
=== CONT TestAccDynamoDBTableItem_basic
=== CONT TestAccDynamoDBTableItem_wonkyItems
--- PASS: TestAccDynamoDBTableItem_basic (27.68s)
=== CONT TestAccDynamoDBTableItem_updateWithRangeKey
--- PASS: TestAccDynamoDBTableItem_wonkyItems (30.16s)
=== CONT TestAccDynamoDBTableItem_disappears
--- PASS: TestAccDynamoDBTableItem_disappears (26.40s)
=== CONT TestAccDynamoDBTableItem_withDuplicateItemsSameRangeKey
--- PASS: TestAccDynamoDBTableItem_updateWithRangeKey (42.22s)
=== CONT TestAccDynamoDBTableItem_withDuplicateItemsDifferentRangeKey
--- PASS: TestAccDynamoDBTableItem_withDuplicateItemsSameRangeKey (20.79s)
=== CONT TestAccDynamoDBTableItem_update
--- PASS: TestAccDynamoDBTableItem_withDuplicateItemsDifferentRangeKey (26.14s)
=== CONT TestAccDynamoDBTableItem_withMultipleItems
--- PASS: TestAccDynamoDBTableItem_update (41.09s)
=== CONT TestAccDynamoDBTableItem_rangeKey
--- PASS: TestAccDynamoDBTableItem_withMultipleItems (25.53s)
--- PASS: TestAccDynamoDBTableItem_rangeKey (25.80s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/dynamodb 146.204s
This functionality has been released in v4.40.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Description
Expected
is a legacy parameter and should no longer be usedExpected
is only checking that the hash key does not exist whereas thisConditionExpression
will check whether an item with the same hash key and range key does not existConditionExpression
works, essentially the condition will always be compared against a single item and so it is sufficient to just check for the existence of the hash keyRelations
Relates #27503
Closes #26080
References