Skip to content
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

Group member order is preserved, causing spurious updates #859

Open
cliffchapmanrbx opened this issue Jun 4, 2024 · 0 comments
Open

Group member order is preserved, causing spurious updates #859

cliffchapmanrbx opened this issue Jun 4, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@cliffchapmanrbx
Copy link

Terraform Version and Provider Version

Terraform version: v1.6.4
HCP provider version: v0.90.0

Affected Resource(s)

  • hcp_group_members

Terraform Configuration Files

locals {
  org_admin_emails = [
    "[email protected]",
    "[email protected]",
    "[email protected]",
    "[email protected]",
  ]
  org_admin_humans = [for u in data.hcp_user_principal.humans : u.user_id]
}

resource "hcp_group" "org-admins" {
  display_name = "Org Admins"
  description  = "Accounts for managing the whole HCP org."
}

resource "hcp_group_members" org-admins {
  group = hcp_group.org-admins.resource_name
    # Note, service principals can't be added to a group.
  members = local.org_admin_humans
}

Debug Output

The order of the list elements changed unexpectedly, causing a spurious change. This is the only relevant output:

Terraform will perform the following actions:

  # hcp_group_members.org-admins will be updated in-place
  ~ resource "hcp_group_members" "org-admins" {
      ~ members = [
          - "38-redacted-5d",
          - "44-redacted-dd",
            "4d-redacted-39",
            "d7-redacted-67",
          + "38-redacted-5d",
          + "44-redacted-dd",
        ]
        # (1 unchanged attribute hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Expected Behavior

The group member list is treated as unordered, and only adding/removing list entries causes a change.

Workaround

Add a sort to the list.

org_admin_humans = sort([for u in data.hcp_user_principal.humans : u.user_id])

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@cliffchapmanrbx cliffchapmanrbx added the bug Something isn't working label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant