Skip to content

r/aws_cognito_identity_provider: Change idp_identifiers to a set 🤖🤖🤖 - #49210

Open
mhorbul wants to merge 2 commits into
hashicorp:mainfrom
mhorbul:b-r/aws_cognito_identity_provider-idp_identifiers-set
Open

r/aws_cognito_identity_provider: Change idp_identifiers to a set 🤖🤖🤖#49210
mhorbul wants to merge 2 commits into
hashicorp:mainfrom
mhorbul:b-r/aws_cognito_identity_provider-idp_identifiers-set

Conversation

@mhorbul

@mhorbul mhorbul commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Rollback Plan

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

Changes to Security Controls

None.

Description

aws_cognito_identity_provider.idp_identifiers was modelled as a TypeList, but Cognito returns the identifiers in its own order, which does not necessarily match the order they were sent in. Whenever the two orders differ, the resource has a permanent diff: every apply rewrites the identifiers with the configured order, DescribeIdentityProvider returns a different order, and the next plan shows the same reordering again.

The order of the identifiers carries no meaning for Cognito, so this changes the attribute to a TypeSet.

CloudTrail for a single affected resource, showing the write and the subsequent read disagreeing (domains redacted):

UpdateIdentityProvider    requestParameters.idpIdentifiers: ["alpha.example.com","beta.example.org"]
DescribeIdentityProvider  IdentityProvider.IdpIdentifiers:  ["beta.example.org","alpha.example.com"]

Existing state written by the previous TypeList schema is read back into the set without a diff or a replacement, so no state upgrade is required. I verified this against real infrastructure that was showing the perpetual diff: a locally built provider with this patch produces No changes. Your infrastructure matches the configuration. for four aws_cognito_identity_provider resources that the released provider wanted to update in-place on every run, with no configuration change.

TestAccCognitoIDPIdentityProvider_idpIdentifiersOrder is a regression test: it applies two identifiers, then reorders them in the configuration and asserts an empty plan.

AI Usage

Disclosed per the AI usage policy. This change was produced with an AI coding agent (Claude Code) working under my direction:

  • The agent diagnosed the root cause from CloudTrail evidence in my own AWS account, wrote the schema and expander changes, wrote the new acceptance test and the test configuration function, and drafted this description.
  • I directed the work, reviewed the diff, and ran the verification myself on my machine: go build, go vet, gofmt, the SDKv2 provider InternalValidate test, and the acceptance tests against a real AWS account.
  • The regression test was validated in both directions: it fails on unpatched code with the exact reported drift, and passes with the change applied. Both runs are included below.

Relations

Closes #46686

References

Output from Acceptance Testing

% make testacc TESTS='TestAccCognitoIDPIdentityProvider_' PKG=cognitoidp

--- PASS: TestAccCognitoIDPIdentityProvider_Disappears_userPool (22.26s)
--- PASS: TestAccCognitoIDPIdentityProvider_disappears (23.00s)
--- PASS: TestAccCognitoIDPIdentityProvider_idpIdentifiersOrder (31.77s)
--- PASS: TestAccCognitoIDPIdentityProvider_basic (37.16s)
--- PASS: TestAccCognitoIDPIdentityProvider_idpIdentifiers (37.51s)
--- PASS: TestAccCognitoIDPIdentityProvider_saml (49.55s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/cognitoidp 55.922s

Without the schema change (new test only, TypeList restored), the new test fails with exactly the reported drift:

% make testacc TESTS='TestAccCognitoIDPIdentityProvider_idpIdentifiersOrder' PKG=cognitoidp

          # aws_cognito_identity_provider.test will be updated in-place
          ~ resource "aws_cognito_identity_provider" "test" {
                id                = "us-east-1_XXXXXXXXX:Google"
              ~ idp_identifiers   = [
                  - "test2",
                    "test1",
                  + "test2",
                ]
                # (6 unchanged attributes hidden)
            }

        Plan: 0 to add, 1 to change, 0 to destroy.
FAIL
FAIL    github.com/hashicorp/terraform-provider-aws/internal/service/cognitoidp 23.839s

Compatibility

idp_identifiers can no longer be indexed. Configurations using aws_cognito_identity_provider.example.idp_identifiers[0], or passing the attribute to functions that require a list such as join, need tolist(). I am happy to retarget this at a major release if you would prefer to hold it. If the type change is not acceptable at all, the alternative is to keep TypeList and suppress the ordering difference with a sorted-comparison DiffSuppressFunc, which I think is more fragile than modelling the attribute correctly.

@mhorbul
mhorbul requested a review from a team as a code owner July 30, 2026 17:10
@dosubot dosubot Bot added the bug Addresses a defect in current functionality. label Jul 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

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

@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/cognitoidp Issues and PRs that pertain to the cognitoidp service. size/M Managed by automation to categorize the size of a PR. labels Jul 30, 2026
mhorbul added 2 commits July 30, 2026 13:25
AWS returns idp_identifiers in its own order, which does not necessarily
match the order in the configuration. Because the attribute was a
TypeList, any mismatch produced a permanent diff: every apply rewrote the
identifiers and the following plan showed the same reordering again.

The order of the identifiers has no meaning to Cognito, so model the
attribute as a TypeSet instead.
@mhorbul
mhorbul force-pushed the b-r/aws_cognito_identity_provider-idp_identifiers-set branch from a99f982 to 13a48a9 Compare July 30, 2026 17:25
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. documentation Introduces or discusses updates to documentation. needs-triage Waiting for first response or review from a maintainer. service/cognitoidp Issues and PRs that pertain to the cognitoidp service. size/M 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.

aws_cognito_identity_provider.idp_identifiers always attempting changes

1 participant