Skip to content

Add support for creating teams with explicit maintainers #3135

@mymasse

Description

@mymasse

Originally posted by @mymasse in #3115

Add deterministic support for create_with_maintainers = [] to github_team so teams can be created and managed by non-privileged users.

The create_default_maintainer deprecation breaks creation of teams when Terraform is run by a non-privileged user. When running terraform with maintainer_username user, a regular user with a PAT with the required permissions (non org-admin). The following will fail:

resource "github_team" "test" {
  name                      = "Test"
  parent_team_id      = github_team.parent.id
  privacy                   = "closed"
}

resource "github_team_members" "test" {
  team_id = github_team.test.id

  members {
    username = "maintainer_username"
    role     = "maintainer"
  }
  members {
    username = "mymasse"
  }
}
github_team.test: Creating...
github_team.test: Creation complete after 3s [id=15957916]
github_team_members.test: Creating...
╷
│ Error: PUT https://api.github.com/organizations/17620943/team/15957916/memberships/trecnoc-terraform: 403 You must be an organization owner or team maintainer to add a team membership. []
│ 
│   with github_team_members.test,
│   on main.tf line 359, in resource "github_team_members" "test":
│  359: resource "github_team_members" "test" {
│ 
╵

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Up for grabsIssues that are ready to be worked on by anyoneType: FeatureNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions