integrations / terraform-provider-github

Terraform GitHub provider
https://www.terraform.io/docs/providers/github/
MIT License
891 stars 736 forks source link

[BUG]: Persistent Drift Issue in `github_branch_protection` Resource Despite No Changes #2243

Open RoseSecurity opened 5 months ago

RoseSecurity commented 5 months ago

Expected Behavior

Within the github_branch_protection resource, I have a restrict_pushes block that allows pushes to the protected branch by fetching the github_user node_id.

  restrict_pushes {
    blocks_creations = var.restrict_pushes_blocks_creations
    push_allowances = var.push_restrictions_enabled ? [
      join("", data.github_user.allowed_user[*].node_id),
    ] : []
  }

Every time I run a plan or apply, it shows drift and that the resource needs to be updated in place although the value remains the same.

Actual Behavior

This is how each plan and apply appears:

  # github_branch_protection.default[0] will be updated in-place
  ~ resource "github_branch_protection" "default" {
        id                              = "BPR_XXXXXXXXXXXX"
        # (10 unchanged attributes hidden)

      ~ restrict_pushes {
          ~ push_allowances  = [
              + "U_XXXXXXXX",
            ]
            # (1 unchanged attribute hidden)
        }

        # (1 unchanged block hidden)
    }

Terraform Version

Terraform v1.5.6 on M1 Mac with integrations/github v6.2.1

Affected Resource(s)

Terraform Configuration Files

No response

Steps to Reproduce

No response

Debug Output

# github_branch_protection.default[0] will be updated in-place
  ~ resource "github_branch_protection" "default" {
        id                              = "BPR_XXXXXXXXXXXX"
        # (10 unchanged attributes hidden)

      ~ restrict_pushes {
          ~ push_allowances  = [
              + "U_XXXXXXXX",
            ]
            # (1 unchanged attribute hidden)
        }

        # (1 unchanged block hidden)
    }

Panic Output

No response

Code of Conduct