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

[BUG]: updating an existing github_repository_collaborators does not propagate changes to invitation_ids to dependent resources #1823

Closed
jsifuentes opened this issue Aug 4, 2023 · 1 comment · Fixed by #1825

Comments

@jsifuentes
Copy link
Contributor

Terraform Version

Terraform v1.5.2
on darwin_arm64

Affected Resource(s)

  • github_repository_collaborators
  • github_user_invitation_accepter

Terraform Configuration Files

The goal is to 1) invite an outside collaborator to a repository and 2) automatically accept the invite from the outside collaborator's perspective.

So to do this you need 2 providers.

provider "github" {
  token = var.inviter_token
}

provider "github" {
  alias = "invitee"
  token = var.invitee_token
}

So first, we want to start off with an existing github_repository_collaborators resource.

# start off with this existing resource already in the Terraform state
resource "github_repository_collaborators" "a_repo_collaborators" {
  repository = github_repository.some_repo.name

  user {
    permission = "admin"
    username  = "SomeUser"
  }
}

next, we want to update the terraform resource and add a new outside collaborator to the repository. This outside collaborator needs to accept an expirable invite, so we'll also add the github_user_invitation_accepter resource.

resource "github_repository_collaborators" "a_repo_collaborators" {
  repository = github_repository.some_repo.name

  user {
    permission = "admin"
    username  = "SomeUser"
  }

  user {
    permission = "admin"
    username  = "AnotherUserOutsideCollaborator"
  }
}

resource "github_user_invitation_accepter" "accepter" {
  provider       = github.invitee
  invitation_id  = try(github_repository_collaborators.collaborators.invitation_ids["AnotherUserOutsideCollaborator"], "")
  allow_empty_id = true
}

Expected Behavior

  • The github_repository_collaborators invitiation_ids attribute is planned with (known after apply)
  • github_user_invitation_accepter.accepter is planned with invitation_id = (known after apply)

Actual Behavior

  • github_repository_collaborators resource is planned
  • github_user_invitation_accepter.accepter is planned with invitation_id = "" so the fact there is a possible change in invitation_ids is not propagated.

Steps to Reproduce

  1. Create a repository in an organization
  2. Create a github_repository_collaborators resource and plan&apply it so the state exists.
  3. Update the github_repository_collaborators resource to invite an outside collaborator
  4. Add the github_user_invitation_accepter resource so the invite from github_repository_collaborators is automatically accepted.
  5. terraform plan and observe that the plan for github_user_invitation_accepter assumes invitation_id is an empty string.
@github-actions
Copy link

github-actions bot commented Aug 4, 2023

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant