Skip to content

github_team is created with the Terraform user added as an extra member #527

Closed as not planned

Description

@morancj

Terraform Version

Terraform v0.12.24

  • provider.aws v2.59.0
  • provider.github v2.8.1

Affected Resource(s)

  • github_team
  • (optionally) github_team_membership

Terraform Configuration Files

resource "github_team" "tftest" {
  name        = "tftest"
  description = "Test team"
  privacy     = "closed"
}

Debug Output

Not relevant: trivial to reproduce. Let me know otherwise, because redacting will take some effort.

Expected Behavior

Team created with no members

Actual Behavior

The user under which terraform is run is silently added as a member to the new team. This membership does not appear in the output or state file.

Steps to Reproduce

Create a new team with or without any github_team_membership entries.
Team will be created with members + terraform_user, if terraform_user is not a member.

Important Factoids

Creating the team through GitHub's Web UI (BUI) automatically adds the user creating the team as a member.

References

Presumably, this is because of:
https://github.com/google/go-github/blob/954e7c82b2994a9f418f300c3f1e147f6a51bd29/github/teams.go#L172:24
and
https://developer.github.com/v3/teams/#create-a-team
The latter states:

When you create a new team, you automatically become a team maintainer without explicitly adding yourself to the optional array of maintainers. For more information, see "About teams" in the GitHub Help documentation.

Activity

  1. sfdc-afraley commented on Sep 15, 2020

    @sfdc-afraley

    This is especially confusing when you're testing with your account and creating teams where you yourself are a member. It adds you as a maintainer, but then a second terraform run will want to change your role. For example:

    resource "github_team" "teams" {
      name        = "team1"
      privacy     = "closed"
    }
    
    resource "github_team_membership" "some_team_membership" {
      team_id  = github_team.teams.id
      username = "myuser"
      role     = "member"
    }
    

    Second TF apply:

    # module.main.github_team_membership.membership["myuser:team1"] will be updated in-place
      ~ resource "github_team_membership" "some_team_membership" {
            id       = "1234567:myuser"
          ~ role     = "maintainer" -> "member"
            team_id  = "1234567"
            username = "myuser"
        }
    
  2. added
    Type: Bug
    on Nov 26, 2020
  3. thekbb commented on Dec 16, 2020

    @thekbb
    Contributor

    Still relevant with
    Terraform 0.13.5
    provider.github 2.9.2

    For context: This would simplify things for me as we're using teams and CODEOWNERS for some approval workflows, and the service account that creates the team shouldn't be able to approve things.

  4. added this to the v4.1.2 milestone on Jan 4, 2021
  5. jcudit commented on Feb 5, 2021

    @jcudit
    Contributor

    Ah, that's a good idea! Read it too late though and merged the workaround instead 🙃 . Seems like the right fix though and we can aim to get that option added in a future release.

  6. added
    Good first issue
    on Feb 5, 2021
  7. added a commit that references this issue on Feb 22, 2021
  8. github-actions commented on Dec 8, 2022

    @github-actions

    👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

  9. added
    Status: Stale
    on Dec 8, 2022
  10. removed
    Status: Stale
    on Dec 9, 2022
  11. github-actions commented on Apr 24, 2024

    @github-actions

    👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

  12. added
    Status: Stale
    on Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good first issueStatus: StaleType: Bugr/team

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions