Skip to content

Conversation

@shawnaws
Copy link
Contributor

@shawnaws shawnaws commented Dec 2, 2025

Rollback Plan

If a change needs to be reverted, we will publish an updated version of the library.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

Description

This change adds support for Multi-Attribute keys in Dynamo DB which was recently added. Documentation page

Relations

Closes #45216

References

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.DesignPattern.MultiAttributeKeys.html

Output from Acceptance Testing

% make build && make testacc PKG=dynamodb TESTS=TestAccDynamoDBTable_extended_gsiMultiHashKey
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
make: Building provider...
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
make: Running acceptance tests on branch: 🌿 f/ddb-gsi-mutlihashrangekey 🌿...
TF_ACC=1 go1.24.10 test ./internal/service/dynamodb/... -v -count 1 -parallel 20 -run='TestAccDynamoDBTable_extended_gsiMultiHashKey'  -timeout 360m -vet=off
2025/12/01 13:45:31 Creating Terraform AWS Provider (SDKv2-style)...
2025/12/01 13:45:31 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN   TestAccDynamoDBTable_extended_gsiMultiHashKey
=== PAUSE TestAccDynamoDBTable_extended_gsiMultiHashKey
=== RUN   TestAccDynamoDBTable_extended_gsiMultiHashKey_transition
    table_test.go:900: Skipping test for validation
--- SKIP: TestAccDynamoDBTable_extended_gsiMultiHashKey_transition (0.00s)
=== RUN   TestAccDynamoDBTable_extended_gsiMultiHashKeyMutliRangeKey_maxSet
=== PAUSE TestAccDynamoDBTable_extended_gsiMultiHashKeyMutliRangeKey_maxSet
=== RUN   TestAccDynamoDBTable_extended_gsiMultiHashKey_singleAndMultiSet
=== PAUSE TestAccDynamoDBTable_extended_gsiMultiHashKey_singleAndMultiSet
=== RUN   TestAccDynamoDBTable_extended_gsiMultiHashKey_tooMany
=== PAUSE TestAccDynamoDBTable_extended_gsiMultiHashKey_tooMany
=== CONT  TestAccDynamoDBTable_extended_gsiMultiHashKey
=== CONT  TestAccDynamoDBTable_extended_gsiMultiHashKey_singleAndMultiSet
=== CONT  TestAccDynamoDBTable_extended_gsiMultiHashKey_tooMany
=== CONT  TestAccDynamoDBTable_extended_gsiMultiHashKeyMutliRangeKey_maxSet
--- PASS: TestAccDynamoDBTable_extended_gsiMultiHashKey_tooMany (2.07s)
--- PASS: TestAccDynamoDBTable_extended_gsiMultiHashKey_singleAndMultiSet (2.62s)
--- PASS: TestAccDynamoDBTable_extended_gsiMultiHashKey (31.54s)
--- PASS: TestAccDynamoDBTable_extended_gsiMultiHashKeyMutliRangeKey_maxSet (41.63s)
PASS
...

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

Community Guidelines

This comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀

Voting for Prioritization

  • Please vote on this Pull Request by adding a 👍 reaction to the original post to help the community and maintainers prioritize it.
  • Please see our prioritization guide for additional information on how the maintainers handle prioritization.
  • Please do not leave +1 or other comments that do not add relevant new information or questions; they generate extra noise for others following the Pull Request and do not help prioritize the request.

Pull Request Authors

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/dynamodb Issues and PRs that pertain to the dynamodb service. size/XL Managed by automation to categorize the size of a PR. partner Contribution from a partner. labels Dec 2, 2025
@shawnaws shawnaws changed the title F/ddb gsi mutlihashrangekey Feature: DynamoDB Multi-Attribute Keys for Global Secondary Index Dec 2, 2025
@shawnaws shawnaws marked this pull request as ready for review December 2, 2025 18:37
@shawnaws shawnaws requested a review from a team as a code owner December 2, 2025 18:37
@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

✅ Thank you for correcting the previously detected issues! The maintainers appreciate your efforts to make the review process as smooth as possible.

"hash_keys": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for my edification, what does computed mean in this context?

Comment on lines +2118 to +2119
if set, ok := hks.(*schema.Set); ok && set.Len() == 0 {
delete(oldAttributes, "hash_keys")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we instead throw error when a customer picks both options?

Comment on lines +2664 to +2673
if len(hashKeys) == 1 {
gsi["hash_key"] = hashKeys[0]
} else if len(hashKeys) > 1 {
gsi["hash_keys"] = hashKeys
}

if len(rangeKeys) == 1 {
gsi["range_key"] = rangeKeys[0]
} else if len(rangeKeys) > 1 {
gsi["range_keys"] = rangeKeys
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we internally always just start using hash_keys and range_keys and the customer facing api model can still contain the single range_key which internally just gets translated to a singleton list of range_keys

Copy link

@roagrawa roagrawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feature wise looks correct behavior, will let terraform expert verify the expected behaviors are enforced correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Introduces or discusses updates to documentation. needs-triage Waiting for first response or review from a maintainer. partner Contribution from a partner. service/dynamodb Issues and PRs that pertain to the dynamodb service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for DynamoDB Multi-Key GSI/Global Secondary Index

2 participants