github.TeamMembership
Explore with Pulumi AI
Provides a GitHub team membership resource.
This resource allows you to add/remove users from teams in your organization. When applied, the user will be added to the team. If the user hasn’t accepted their invitation to the organization, they won’t be part of the team until they do. When destroyed, the user will be removed from the team.
Note This resource is not compatible with
github.TeamMembers
. Use eithergithub.TeamMembers
orgithub.TeamMembership
.
Note Organization owners may not be set as “members” of a team; they may only be set as “maintainers”. Attempting to set organization an owner to “member” of a may result in a
pulumi preview
diff that changes their status back to “maintainer”.
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 someTeam = new github.Team("some_team", {
name: "SomeTeam",
description: "Some cool team",
});
const someTeamMembership = new github.TeamMembership("some_team_membership", {
teamId: someTeam.id,
username: "SomeUser",
role: "member",
});
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")
some_team = github.Team("some_team",
name="SomeTeam",
description="Some cool team")
some_team_membership = github.TeamMembership("some_team_membership",
team_id=some_team.id,
username="SomeUser",
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 {
// 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
}
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.NewTeamMembership(ctx, "some_team_membership", &github.TeamMembershipArgs{
TeamId: someTeam.ID(),
Username: pulumi.String("SomeUser"),
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(() =>
{
// Add a user to the organization
var membershipForSomeUser = new Github.Membership("membership_for_some_user", new()
{
Username = "SomeUser",
Role = "member",
});
var someTeam = new Github.Team("some_team", new()
{
Name = "SomeTeam",
Description = "Some cool team",
});
var someTeamMembership = new Github.TeamMembership("some_team_membership", new()
{
TeamId = someTeam.Id,
Username = "SomeUser",
Role = "member",
});
});
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.TeamMembership;
import com.pulumi.github.TeamMembershipArgs;
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 someTeam = new Team("someTeam", TeamArgs.builder()
.name("SomeTeam")
.description("Some cool team")
.build());
var someTeamMembership = new TeamMembership("someTeamMembership", TeamMembershipArgs.builder()
.teamId(someTeam.id())
.username("SomeUser")
.role("member")
.build());
}
}
resources:
# Add a user to the organization
membershipForSomeUser:
type: github:Membership
name: membership_for_some_user
properties:
username: SomeUser
role: member
someTeam:
type: github:Team
name: some_team
properties:
name: SomeTeam
description: Some cool team
someTeamMembership:
type: github:TeamMembership
name: some_team_membership
properties:
teamId: ${someTeam.id}
username: SomeUser
role: member
Create TeamMembership Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new TeamMembership(name: string, args: TeamMembershipArgs, opts?: CustomResourceOptions);
@overload
def TeamMembership(resource_name: str,
args: TeamMembershipArgs,
opts: Optional[ResourceOptions] = None)
@overload
def TeamMembership(resource_name: str,
opts: Optional[ResourceOptions] = None,
team_id: Optional[str] = None,
username: Optional[str] = None,
role: Optional[str] = None)
func NewTeamMembership(ctx *Context, name string, args TeamMembershipArgs, opts ...ResourceOption) (*TeamMembership, error)
public TeamMembership(string name, TeamMembershipArgs args, CustomResourceOptions? opts = null)
public TeamMembership(String name, TeamMembershipArgs args)
public TeamMembership(String name, TeamMembershipArgs args, CustomResourceOptions options)
type: github:TeamMembership
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args TeamMembershipArgs
- 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 TeamMembershipArgs
- 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 TeamMembershipArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args TeamMembershipArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args TeamMembershipArgs
- 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 teamMembershipResource = new Github.TeamMembership("teamMembershipResource", new()
{
TeamId = "string",
Username = "string",
Role = "string",
});
example, err := github.NewTeamMembership(ctx, "teamMembershipResource", &github.TeamMembershipArgs{
TeamId: pulumi.String("string"),
Username: pulumi.String("string"),
Role: pulumi.String("string"),
})
var teamMembershipResource = new TeamMembership("teamMembershipResource", TeamMembershipArgs.builder()
.teamId("string")
.username("string")
.role("string")
.build());
team_membership_resource = github.TeamMembership("teamMembershipResource",
team_id="string",
username="string",
role="string")
const teamMembershipResource = new github.TeamMembership("teamMembershipResource", {
teamId: "string",
username: "string",
role: "string",
});
type: github:TeamMembership
properties:
role: string
teamId: string
username: string
TeamMembership Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The TeamMembership resource accepts the following input properties:
Outputs
All input properties are implicitly available as output properties. Additionally, the TeamMembership resource produces the following output properties:
Look up Existing TeamMembership Resource
Get an existing TeamMembership 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?: TeamMembershipState, opts?: CustomResourceOptions): TeamMembership
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
etag: Optional[str] = None,
role: Optional[str] = None,
team_id: Optional[str] = None,
username: Optional[str] = None) -> TeamMembership
func GetTeamMembership(ctx *Context, name string, id IDInput, state *TeamMembershipState, opts ...ResourceOption) (*TeamMembership, error)
public static TeamMembership Get(string name, Input<string> id, TeamMembershipState? state, CustomResourceOptions? opts = null)
public static TeamMembership get(String name, Output<String> id, TeamMembershipState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- 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.
Import
GitHub Team Membership can be imported using an ID made up of teamid:username
or teamname:username
, e.g.
$ pulumi import github:index/teamMembership:TeamMembership member 1234567:someuser
$ pulumi import github:index/teamMembership:TeamMembership member Administrators:someuser
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.