1. Packages
  2. Github Provider
  3. API Docs
  4. TeamMembers
GitHub v6.7.0 published on Friday, Feb 28, 2025 by Pulumi

github.TeamMembers

Explore with Pulumi AI

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as github from "@pulumi/github";

// Add a user to the organization
const membershipForSomeUser = new github.Membership("membership_for_some_user", {
    username: "SomeUser",
    role: "member",
});
const membershipForAnotherUser = new github.Membership("membership_for_another_user", {
    username: "AnotherUser",
    role: "member",
});
const someTeam = new github.Team("some_team", {
    name: "SomeTeam",
    description: "Some cool team",
});
const someTeamMembers = new github.TeamMembers("some_team_members", {
    teamId: someTeam.id,
    members: [
        {
            username: "SomeUser",
            role: "maintainer",
        },
        {
            username: "AnotherUser",
            role: "member",
        },
    ],
});
Copy
import pulumi
import pulumi_github as github

# Add a user to the organization
membership_for_some_user = github.Membership("membership_for_some_user",
    username="SomeUser",
    role="member")
membership_for_another_user = github.Membership("membership_for_another_user",
    username="AnotherUser",
    role="member")
some_team = github.Team("some_team",
    name="SomeTeam",
    description="Some cool team")
some_team_members = github.TeamMembers("some_team_members",
    team_id=some_team.id,
    members=[
        {
            "username": "SomeUser",
            "role": "maintainer",
        },
        {
            "username": "AnotherUser",
            "role": "member",
        },
    ])
Copy
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 {
		// Add a user to the organization
		_, err := github.NewMembership(ctx, "membership_for_some_user", &github.MembershipArgs{
			Username: pulumi.String("SomeUser"),
			Role:     pulumi.String("member"),
		})
		if err != nil {
			return err
		}
		_, err = github.NewMembership(ctx, "membership_for_another_user", &github.MembershipArgs{
			Username: pulumi.String("AnotherUser"),
			Role:     pulumi.String("member"),
		})
		if err != nil {
			return err
		}
		someTeam, err := github.NewTeam(ctx, "some_team", &github.TeamArgs{
			Name:        pulumi.String("SomeTeam"),
			Description: pulumi.String("Some cool team"),
		})
		if err != nil {
			return err
		}
		_, err = github.NewTeamMembers(ctx, "some_team_members", &github.TeamMembersArgs{
			TeamId: someTeam.ID(),
			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
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Github = Pulumi.Github;

return await Deployment.RunAsync(() => 
{
    // Add a user to the organization
    var membershipForSomeUser = new Github.Membership("membership_for_some_user", new()
    {
        Username = "SomeUser",
        Role = "member",
    });

    var membershipForAnotherUser = new Github.Membership("membership_for_another_user", new()
    {
        Username = "AnotherUser",
        Role = "member",
    });

    var someTeam = new Github.Team("some_team", new()
    {
        Name = "SomeTeam",
        Description = "Some cool team",
    });

    var someTeamMembers = new Github.TeamMembers("some_team_members", new()
    {
        TeamId = someTeam.Id,
        Members = new[]
        {
            new Github.Inputs.TeamMembersMemberArgs
            {
                Username = "SomeUser",
                Role = "maintainer",
            },
            new Github.Inputs.TeamMembersMemberArgs
            {
                Username = "AnotherUser",
                Role = "member",
            },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.github.Membership;
import com.pulumi.github.MembershipArgs;
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.List;
import java.util.ArrayList;
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) {
        // Add a user to the organization
        var membershipForSomeUser = new Membership("membershipForSomeUser", MembershipArgs.builder()
            .username("SomeUser")
            .role("member")
            .build());

        var membershipForAnotherUser = new Membership("membershipForAnotherUser", MembershipArgs.builder()
            .username("AnotherUser")
            .role("member")
            .build());

        var someTeam = new Team("someTeam", TeamArgs.builder()
            .name("SomeTeam")
            .description("Some cool team")
            .build());

        var someTeamMembers = new TeamMembers("someTeamMembers", TeamMembersArgs.builder()
            .teamId(someTeam.id())
            .members(            
                TeamMembersMemberArgs.builder()
                    .username("SomeUser")
                    .role("maintainer")
                    .build(),
                TeamMembersMemberArgs.builder()
                    .username("AnotherUser")
                    .role("member")
                    .build())
            .build());

    }
}
Copy
resources:
  # Add a user to the organization
  membershipForSomeUser:
    type: github:Membership
    name: membership_for_some_user
    properties:
      username: SomeUser
      role: member
  membershipForAnotherUser:
    type: github:Membership
    name: membership_for_another_user
    properties:
      username: AnotherUser
      role: member
  someTeam:
    type: github:Team
    name: some_team
    properties:
      name: SomeTeam
      description: Some cool team
  someTeamMembers:
    type: github:TeamMembers
    name: some_team_members
    properties:
      teamId: ${someTeam.id}
      members:
        - username: SomeUser
          role: maintainer
        - username: AnotherUser
          role: member
Copy

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)
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.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. TeamMembersArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. 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 This property is required. string
The unique name of the resource.
args This property is required. TeamMembersArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. TeamMembersArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. 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",
        },
    },
    TeamId = "string",
});
Copy
example, err := github.NewTeamMembers(ctx, "teamMembersResource", &github.TeamMembersArgs{
	Members: github.TeamMembersMemberArray{
		&github.TeamMembersMemberArgs{
			Username: pulumi.String("string"),
			Role:     pulumi.String("string"),
		},
	},
	TeamId: pulumi.String("string"),
})
Copy
var teamMembersResource = new TeamMembers("teamMembersResource", TeamMembersArgs.builder()
    .members(TeamMembersMemberArgs.builder()
        .username("string")
        .role("string")
        .build())
    .teamId("string")
    .build());
Copy
team_members_resource = github.TeamMembers("teamMembersResource",
    members=[{
        "username": "string",
        "role": "string",
    }],
    team_id="string")
Copy
const teamMembersResource = new github.TeamMembers("teamMembersResource", {
    members: [{
        username: "string",
        role: "string",
    }],
    teamId: "string",
});
Copy
type: github:TeamMembers
properties:
    members:
        - role: string
          username: string
    teamId: string
Copy

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 This property is required. List<TeamMembersMember>
List of team members. See Members below for details.
TeamId
This property is required.
Changes to this property will trigger replacement.
string

The team id or the team slug

Note Although the team id or team slug can be used it is recommended to use the team id. Using the team slug will cause the team members associations to the team to be destroyed and recreated if the team name is updated.

Members This property is required. []TeamMembersMemberArgs
List of team members. See Members below for details.
TeamId
This property is required.
Changes to this property will trigger replacement.
string

The team id or the team slug

Note Although the team id or team slug can be used it is recommended to use the team id. Using the team slug will cause the team members associations to the team to be destroyed and recreated if the team name is updated.

members This property is required. List<TeamMembersMember>
List of team members. See Members below for details.
teamId
This property is required.
Changes to this property will trigger replacement.
String

The team id or the team slug

Note Although the team id or team slug can be used it is recommended to use the team id. Using the team slug will cause the team members associations to the team to be destroyed and recreated if the team name is updated.

members This property is required. TeamMembersMember[]
List of team members. See Members below for details.
teamId
This property is required.
Changes to this property will trigger replacement.
string

The team id or the team slug

Note Although the team id or team slug can be used it is recommended to use the team id. Using the team slug will cause the team members associations to the team to be destroyed and recreated if the team name is updated.

members This property is required. Sequence[TeamMembersMemberArgs]
List of team members. See Members below for details.
team_id
This property is required.
Changes to this property will trigger replacement.
str

The team id or the team slug

Note Although the team id or team slug can be used it is recommended to use the team id. Using the team slug will cause the team members associations to the team to be destroyed and recreated if the team name is updated.

members This property is required. List<Property Map>
List of team members. See Members below for details.
teamId
This property is required.
Changes to this property will trigger replacement.
String

The team id or the team slug

Note Although the team id or team slug can be used it is recommended to use the team id. Using the team slug will cause the team members associations to the team to be destroyed and recreated if the team name is updated.

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 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) -> 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}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 team members. See Members below for details.
TeamId Changes to this property will trigger replacement. string

The team id or the team slug

Note Although the team id or team slug can be used it is recommended to use the team id. Using the team slug will cause the team members associations to the team to be destroyed and recreated if the team name is updated.

Members []TeamMembersMemberArgs
List of team members. See Members below for details.
TeamId Changes to this property will trigger replacement. string

The team id or the team slug

Note Although the team id or team slug can be used it is recommended to use the team id. Using the team slug will cause the team members associations to the team to be destroyed and recreated if the team name is updated.

members List<TeamMembersMember>
List of team members. See Members below for details.
teamId Changes to this property will trigger replacement. String

The team id or the team slug

Note Although the team id or team slug can be used it is recommended to use the team id. Using the team slug will cause the team members associations to the team to be destroyed and recreated if the team name is updated.

members TeamMembersMember[]
List of team members. See Members below for details.
teamId Changes to this property will trigger replacement. string

The team id or the team slug

Note Although the team id or team slug can be used it is recommended to use the team id. Using the team slug will cause the team members associations to the team to be destroyed and recreated if the team name is updated.

members Sequence[TeamMembersMemberArgs]
List of team members. See Members below for details.
team_id Changes to this property will trigger replacement. str

The team id or the team slug

Note Although the team id or team slug can be used it is recommended to use the team id. Using the team slug will cause the team members associations to the team to be destroyed and recreated if the team name is updated.

members List<Property Map>
List of team members. See Members below for details.
teamId Changes to this property will trigger replacement. String

The team id or the team slug

Note Although the team id or team slug can be used it is recommended to use the team id. Using the team slug will cause the team members associations to the team to be destroyed and recreated if the team name is updated.

Supporting Types

TeamMembersMember
, TeamMembersMemberArgs

Username This property is required. string
The user to add to the team.
Role string
The role of the user within the team. Must be one of member or maintainer. Defaults to member.
Username This property is required. string
The user to add to the team.
Role string
The role of the user within the team. Must be one of member or maintainer. Defaults to member.
username This property is required. String
The user to add to the team.
role String
The role of the user within the team. Must be one of member or maintainer. Defaults to member.
username This property is required. string
The user to add to the team.
role string
The role of the user within the team. Must be one of member or maintainer. Defaults to member.
username This property is required. str
The user to add to the team.
role str
The role of the user within the team. Must be one of member or maintainer. Defaults to member.
username This property is required. String
The user to add to the team.
role String
The role of the user within the team. Must be one of member or maintainer. Defaults to member.

Import

~> Note Although the team id or team slug can be used it is recommended to use the team id. Using the team slug will result in terraform doing conversions between the team slug and team id. This will cause team members associations to the team to be destroyed and recreated on import.

GitHub Team Membership can be imported using the team ID team id or team slug, e.g.

$ pulumi import github:index/teamMembers:TeamMembers some_team 1234567
Copy
$ pulumi import github:index/teamMembers:TeamMembers some_team Administrators
Copy

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.