Skip to content

Conversation

kamalbennani
Copy link

@kamalbennani kamalbennani commented Oct 1, 2025

Rollback Plan

If a change needs to be reverted, we will revert the commit and publish an updated version of the provider.

Changes to Security Controls

No changes to security controls in this pull request.

Description

Reverts caching_keys field from TypeSet back to TypeList in the aws_appsync_resolver resource to preserve the order of caching keys, which is critical for proper cache key generation in AWS AppSync.

Issue: The caching_keys field was changed to TypeSet in PR #12747, which caused the keys to be reordered alphabetically (due to TypeSet using hashing). This resulted in:

  • Incorrect cache behavior: Different order = different cache key = cache misses
  • Terraform plan drift: Users saw unexpected reordering in plan output
  • Cache invalidation issues: Unable to properly evict cached data

Root Cause: TypeSet is an unordered collection that uses hashing to determine element order. According to AWS AppSync documentation, the order of caching keys is crucial because it determines how cache entries are indexed and retrieved.

Changes Made:

  1. Schema Definition: Changed caching_keys from schema.TypeSet to schema.TypeList
  2. Expand Function: Updated from flex.ExpandStringValueSet() to flex.ExpandStringValueList()
  3. Test Enhancements: Added assertions to verify caching keys order is preserved:
    • caching_keys.0 = "$context.identity.sub"
    • caching_keys.1 = "$context.arguments.id"

Impact: This ensures that the order specified in Terraform configuration is preserved and sent to AWS AppSync exactly as defined, fixing the cache invalidation and drift issues reported by users.

Relations

Closes #42495

References

Output from Acceptance Testing

❯ go test -v -run="TestAccAppSync_serial/Resolver/caching" ./internal/service/appsync -timeout 180m
2025/10/01 08:22:24 Creating Terraform AWS Provider (SDKv2-style)...
2025/10/01 08:22:25 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN   TestAccAppSync_serial
=== PAUSE TestAccAppSync_serial
=== CONT  TestAccAppSync_serial
=== RUN   TestAccAppSync_serial/Resolver
=== RUN   TestAccAppSync_serial/Resolver/caching
    resolver_test.go:339: Acceptance tests skipped unless env 'TF_ACC' set
--- PASS: TestAccAppSync_serial (0.00s)
    --- PASS: TestAccAppSync_serial/Resolver (0.00s)
        --- SKIP: TestAccAppSync_serial/Resolver/caching (0.00s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/appsync	18.677s

Test validation: The test at internal/service/appsync/resolver_test.go:333-360 now includes order verification:

resource.TestCheckResourceAttr(resourceName, "caching_config.0.caching_keys.#", "2"),
resource.TestCheckResourceAttr(resourceName, "caching_config.0.caching_keys.0", "$context.identity.sub"),
resource.TestCheckResourceAttr(resourceName, "caching_config.0.caching_keys.1", "$context.arguments.id"),

@kamalbennani kamalbennani requested a review from a team as a code owner October 1, 2025 06:20
Copy link
Contributor

github-actions bot commented Oct 1, 2025

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

Copy link
Contributor

github-actions bot commented Oct 1, 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. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/appsync Issues and PRs that pertain to the appsync service. size/XS Managed by automation to categorize the size of a PR. labels Oct 1, 2025
@erolaran
Copy link

erolaran commented Oct 1, 2025

👍

@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Oct 1, 2025
@kamalbennani
Copy link
Author

Hey @justinretzolk thanks for triaging this PR.
Any ETA on when this could go live?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/appsync Issues and PRs that pertain to the appsync service. size/XS 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.

caching_config.caching_keys order change (alphabetical order)
4 participants