1. Registry
  2. Packages
  3. Github Provider
  4. API Docs
  5. TeamMembers
Viewing docs for GitHub v6.15.0
published on Friday, Aug 14, 2026 by Pulumi
github logo github logo
Viewing docs for GitHub v6.15.0
published on Friday, Aug 14, 2026 by Pulumi

    This resource is not compatible with github.TeamMembership; use either github.TeamMembers or github.TeamMembership.

    Resource to authoritatively manage GitHub team members.

    This resource allows you to manage members of teams in your organization; it sets the requested team members for the team and removes all users not managed by Terraform. If an organization owner is given the member role they will be granted maintainer instead which will result in a perpetual diff. If a user who hasn’t accepted their invitation to the organization is added to the team, they will not be a team member until they’ve accepted the invitation. When this resource is deleted all users will be removed from the team.

    If you don’t have a member with the maintainer set then this resource may end up with a perpetual diff as the GitHub API will automatically promote a member to maintainer if there are no maintainers in the team. To avoid this, ensure that at least one member has the maintainer role.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as github from "@pulumi/github";
    
    const example = new github.Team("example", {name: "my-team"});
    const exampleTeamMembers = new github.TeamMembers("example", {
        teamSlug: example.slug,
        members: [
            {
                username: "SomeUser",
                role: "maintainer",
            },
            {
                username: "AnotherUser",
                role: "member",
            },
        ],
    });
    
    import pulumi
    import pulumi_github as github
    
    example = github.Team("example", name="my-team")
    example_team_members = github.TeamMembers("example",
        team_slug=example.slug,
        members=[
            {
                "username": "SomeUser",
                "role": "maintainer",
            },
            {
                "username": "AnotherUser",
                "role": "member",
            },
        ])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-github/sdk/v6/go/github"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := github.NewTeam(ctx, "example", &github.TeamArgs{
    			Name: pulumi.String("my-team"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = github.NewTeamMembers(ctx, "example", &github.TeamMembersArgs{
    			TeamSlug: example.Slug,
    			Members: github.TeamMembersMemberArray{
    				&github.TeamMembersMemberArgs{
    					Username: pulumi.String("SomeUser"),
    					Role:     pulumi.String("maintainer"),
    				},
    				&github.TeamMembersMemberArgs{
    					Username: pulumi.String("AnotherUser"),
    					Role:     pulumi.String("member"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Github = Pulumi.Github;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new Github.Team("example", new()
        {
            Name = "my-team",
        });
    
        var exampleTeamMembers = new Github.TeamMembers("example", new()
        {
            TeamSlug = example.Slug,
            Members = new[]
            {
                new Github.Inputs.TeamMembersMemberArgs
                {
                    Username = "SomeUser",
                    Role = "maintainer",
                },
                new Github.Inputs.TeamMembersMemberArgs
                {
                    Username = "AnotherUser",
                    Role = "member",
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.github.Team;
    import com.pulumi.github.TeamArgs;
    import com.pulumi.github.TeamMembers;
    import com.pulumi.github.TeamMembersArgs;
    import com.pulumi.github.inputs.TeamMembersMemberArgs;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var example = new Team("example", TeamArgs.builder()
                .name("my-team")
                .build());
    
            var exampleTeamMembers = new TeamMembers("exampleTeamMembers", TeamMembersArgs.builder()
                .teamSlug(example.slug())
                .members(            
                    TeamMembersMemberArgs.builder()
                        .username("SomeUser")
                        .role("maintainer")
                        .build(),
                    TeamMembersMemberArgs.builder()
                        .username("AnotherUser")
                        .role("member")
                        .build())
                .build());
    
        }
    }
    
    resources:
      example:
        type: github:Team
        properties:
          name: my-team
      exampleTeamMembers:
        type: github:TeamMembers
        name: example
        properties:
          teamSlug: ${example.slug}
          members:
            - username: SomeUser
              role: maintainer
            - username: AnotherUser
              role: member
    
    pulumi {
      required_providers {
        github = {
          source = "pulumi/github"
        }
      }
    }
    
    resource "github_team" "example" {
      name = "my-team"
    }
    resource "github_teammembers" "example" {
      team_slug = github_team.example.slug
      members {
        username = "SomeUser"
        role     = "maintainer"
      }
      members {
        username = "AnotherUser"
        role     = "member"
      }
    }
    

    Create TeamMembers Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new TeamMembers(name: string, args: TeamMembersArgs, opts?: CustomResourceOptions);
    @overload
    def TeamMembers(resource_name: str,
                    args: TeamMembersArgs,
                    opts: Optional[ResourceOptions] = None)
    
    @overload
    def TeamMembers(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    members: Optional[Sequence[TeamMembersMemberArgs]] = None,
                    team_id: Optional[str] = None,
                    team_slug: Optional[str] = None)
    func NewTeamMembers(ctx *Context, name string, args TeamMembersArgs, opts ...ResourceOption) (*TeamMembers, error)
    public TeamMembers(string name, TeamMembersArgs args, CustomResourceOptions? opts = null)
    public TeamMembers(String name, TeamMembersArgs args)
    public TeamMembers(String name, TeamMembersArgs args, CustomResourceOptions options)
    
    type: github:TeamMembers
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    resource "github_team_members" "name" {
        # resource properties
    }

    Parameters

    name string
    The unique name of the resource.
    args TeamMembersArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args TeamMembersArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args TeamMembersArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args TeamMembersArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args TeamMembersArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var teamMembersResource = new Github.TeamMembers("teamMembersResource", new()
    {
        Members = new[]
        {
            new Github.Inputs.TeamMembersMemberArgs
            {
                Username = "string",
                Role = "string",
            },
        },
        TeamSlug = "string",
    });
    
    example, err := github.NewTeamMembers(ctx, "teamMembersResource", &github.TeamMembersArgs{
    	Members: github.TeamMembersMemberArray{
    		&github.TeamMembersMemberArgs{
    			Username: pulumi.String("string"),
    			Role:     pulumi.String("string"),
    		},
    	},
    	TeamSlug: pulumi.String("string"),
    })
    
    resource "github_team_members" "teamMembersResource" {
      lifecycle {
        create_before_destroy = true
      }
      members {
        username = "string"
        role     = "string"
      }
      team_slug = "string"
    }
    
    var teamMembersResource = new TeamMembers("teamMembersResource", TeamMembersArgs.builder()
        .members(TeamMembersMemberArgs.builder()
            .username("string")
            .role("string")
            .build())
        .teamSlug("string")
        .build());
    
    team_members_resource = github.TeamMembers("teamMembersResource",
        members=[{
            "username": "string",
            "role": "string",
        }],
        team_slug="string")
    
    const teamMembersResource = new github.TeamMembers("teamMembersResource", {
        members: [{
            username: "string",
            role: "string",
        }],
        teamSlug: "string",
    });
    
    type: github:TeamMembers
    properties:
        members:
            - role: string
              username: string
        teamSlug: string
    

    TeamMembers Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The TeamMembers resource accepts the following input properties:

    Members List<TeamMembersMember>
    List of users that should be members of the team.
    TeamId string
    ID or slug of the GitHub team to manage membership for.

    Deprecated: Use teamSlug instead; this field will be made computed only in a future version of the provider.

    TeamSlug string
    Slug of the GitHub team to manage membership for.
    Members []TeamMembersMemberArgs
    List of users that should be members of the team.
    TeamId string
    ID or slug of the GitHub team to manage membership for.

    Deprecated: Use teamSlug instead; this field will be made computed only in a future version of the provider.

    TeamSlug string
    Slug of the GitHub team to manage membership for.
    members list(object)
    List of users that should be members of the team.
    team_id string
    ID or slug of the GitHub team to manage membership for.

    Deprecated: Use teamSlug instead; this field will be made computed only in a future version of the provider.

    team_slug string
    Slug of the GitHub team to manage membership for.
    members List<TeamMembersMember>
    List of users that should be members of the team.
    teamId String
    ID or slug of the GitHub team to manage membership for.

    Deprecated: Use teamSlug instead; this field will be made computed only in a future version of the provider.

    teamSlug String
    Slug of the GitHub team to manage membership for.
    members TeamMembersMember[]
    List of users that should be members of the team.
    teamId string
    ID or slug of the GitHub team to manage membership for.

    Deprecated: Use teamSlug instead; this field will be made computed only in a future version of the provider.

    teamSlug string
    Slug of the GitHub team to manage membership for.
    members Sequence[TeamMembersMemberArgs]
    List of users that should be members of the team.
    team_id str
    ID or slug of the GitHub team to manage membership for.

    Deprecated: Use teamSlug instead; this field will be made computed only in a future version of the provider.

    team_slug str
    Slug of the GitHub team to manage membership for.
    members List<Property Map>
    List of users that should be members of the team.
    teamId String
    ID or slug of the GitHub team to manage membership for.

    Deprecated: Use teamSlug instead; this field will be made computed only in a future version of the provider.

    teamSlug String
    Slug of the GitHub team to manage membership for.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the TeamMembers resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing TeamMembers Resource

    Get an existing TeamMembers resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: TeamMembersState, opts?: CustomResourceOptions): TeamMembers
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            members: Optional[Sequence[TeamMembersMemberArgs]] = None,
            team_id: Optional[str] = None,
            team_slug: Optional[str] = None) -> TeamMembers
    func GetTeamMembers(ctx *Context, name string, id IDInput, state *TeamMembersState, opts ...ResourceOption) (*TeamMembers, error)
    public static TeamMembers Get(string name, Input<string> id, TeamMembersState? state, CustomResourceOptions? opts = null)
    public static TeamMembers get(String name, Output<String> id, TeamMembersState state, CustomResourceOptions options)
    resources:  _:    type: github:TeamMembers    get:      id: ${id}
    import {
      to = github_team_members.example
      id = "${id}"
    }
    
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Members List<TeamMembersMember>
    List of users that should be members of the team.
    TeamId string
    ID or slug of the GitHub team to manage membership for.

    Deprecated: Use teamSlug instead; this field will be made computed only in a future version of the provider.

    TeamSlug string
    Slug of the GitHub team to manage membership for.
    Members []TeamMembersMemberArgs
    List of users that should be members of the team.
    TeamId string
    ID or slug of the GitHub team to manage membership for.

    Deprecated: Use teamSlug instead; this field will be made computed only in a future version of the provider.

    TeamSlug string
    Slug of the GitHub team to manage membership for.
    members list(object)
    List of users that should be members of the team.
    team_id string
    ID or slug of the GitHub team to manage membership for.

    Deprecated: Use teamSlug instead; this field will be made computed only in a future version of the provider.

    team_slug string
    Slug of the GitHub team to manage membership for.
    members List<TeamMembersMember>
    List of users that should be members of the team.
    teamId String
    ID or slug of the GitHub team to manage membership for.

    Deprecated: Use teamSlug instead; this field will be made computed only in a future version of the provider.

    teamSlug String
    Slug of the GitHub team to manage membership for.
    members TeamMembersMember[]
    List of users that should be members of the team.
    teamId string
    ID or slug of the GitHub team to manage membership for.

    Deprecated: Use teamSlug instead; this field will be made computed only in a future version of the provider.

    teamSlug string
    Slug of the GitHub team to manage membership for.
    members Sequence[TeamMembersMemberArgs]
    List of users that should be members of the team.
    team_id str
    ID or slug of the GitHub team to manage membership for.

    Deprecated: Use teamSlug instead; this field will be made computed only in a future version of the provider.

    team_slug str
    Slug of the GitHub team to manage membership for.
    members List<Property Map>
    List of users that should be members of the team.
    teamId String
    ID or slug of the GitHub team to manage membership for.

    Deprecated: Use teamSlug instead; this field will be made computed only in a future version of the provider.

    teamSlug String
    Slug of the GitHub team to manage membership for.

    Supporting Types

    TeamMembersMember, TeamMembersMemberArgs

    Username string
    User to add to the team.
    Role string
    Role to grant the user within the team; must be one of member or maintainer.
    Username string
    User to add to the team.
    Role string
    Role to grant the user within the team; must be one of member or maintainer.
    username string
    User to add to the team.
    role string
    Role to grant the user within the team; must be one of member or maintainer.
    username String
    User to add to the team.
    role String
    Role to grant the user within the team; must be one of member or maintainer.
    username string
    User to add to the team.
    role string
    Role to grant the user within the team; must be one of member or maintainer.
    username str
    User to add to the team.
    role str
    Role to grant the user within the team; must be one of member or maintainer.
    username String
    User to add to the team.
    role String
    Role to grant the user within the team; must be one of member or maintainer.

    Import

    This resource can be imported either by the team slug or team ID; it is recommended to use the team slug in combination with the teamSlug resource attribute.

    The pulumi import command can be used, for example:

    $ pulumi import github:index/teamMembers:TeamMembers example my-team
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    GitHub pulumi/pulumi-github
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the github Terraform Provider.
    github logo github logo
    Viewing docs for GitHub v6.15.0
    published on Friday, Aug 14, 2026 by Pulumi

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial