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

github.TeamRepository

Explore with Pulumi AI

Note: github.TeamRepository cannot be used in conjunction with github.RepositoryCollaborators or they will fight over what your policy should be.

This resource manages relationships between teams and repositories in your GitHub organization.

Creating this resource grants a particular team permissions on a particular repository.

The repository and the team must both belong to the same organization on GitHub. This resource does not actually create any repositories; to do that, see github.Repository.

This resource is non-authoritative, for managing ALL collaborators of a repo, use github.RepositoryCollaborators instead.

Example Usage

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

// Add a repository to the team
const someTeam = new github.Team("some_team", {
    name: "SomeTeam",
    description: "Some cool team",
});
const someRepo = new github.Repository("some_repo", {name: "some-repo"});
const someTeamRepo = new github.TeamRepository("some_team_repo", {
    teamId: someTeam.id,
    repository: someRepo.name,
    permission: "pull",
});
Copy
import pulumi
import pulumi_github as github

# Add a repository to the team
some_team = github.Team("some_team",
    name="SomeTeam",
    description="Some cool team")
some_repo = github.Repository("some_repo", name="some-repo")
some_team_repo = github.TeamRepository("some_team_repo",
    team_id=some_team.id,
    repository=some_repo.name,
    permission="pull")
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 repository to the team
		someTeam, err := github.NewTeam(ctx, "some_team", &github.TeamArgs{
			Name:        pulumi.String("SomeTeam"),
			Description: pulumi.String("Some cool team"),
		})
		if err != nil {
			return err
		}
		someRepo, err := github.NewRepository(ctx, "some_repo", &github.RepositoryArgs{
			Name: pulumi.String("some-repo"),
		})
		if err != nil {
			return err
		}
		_, err = github.NewTeamRepository(ctx, "some_team_repo", &github.TeamRepositoryArgs{
			TeamId:     someTeam.ID(),
			Repository: someRepo.Name,
			Permission: pulumi.String("pull"),
		})
		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 repository to the team
    var someTeam = new Github.Team("some_team", new()
    {
        Name = "SomeTeam",
        Description = "Some cool team",
    });

    var someRepo = new Github.Repository("some_repo", new()
    {
        Name = "some-repo",
    });

    var someTeamRepo = new Github.TeamRepository("some_team_repo", new()
    {
        TeamId = someTeam.Id,
        Repository = someRepo.Name,
        Permission = "pull",
    });

});
Copy
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.Repository;
import com.pulumi.github.RepositoryArgs;
import com.pulumi.github.TeamRepository;
import com.pulumi.github.TeamRepositoryArgs;
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 repository to the team
        var someTeam = new Team("someTeam", TeamArgs.builder()
            .name("SomeTeam")
            .description("Some cool team")
            .build());

        var someRepo = new Repository("someRepo", RepositoryArgs.builder()
            .name("some-repo")
            .build());

        var someTeamRepo = new TeamRepository("someTeamRepo", TeamRepositoryArgs.builder()
            .teamId(someTeam.id())
            .repository(someRepo.name())
            .permission("pull")
            .build());

    }
}
Copy
resources:
  # Add a repository to the team
  someTeam:
    type: github:Team
    name: some_team
    properties:
      name: SomeTeam
      description: Some cool team
  someRepo:
    type: github:Repository
    name: some_repo
    properties:
      name: some-repo
  someTeamRepo:
    type: github:TeamRepository
    name: some_team_repo
    properties:
      teamId: ${someTeam.id}
      repository: ${someRepo.name}
      permission: pull
Copy

Create TeamRepository Resource

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

Constructor syntax

new TeamRepository(name: string, args: TeamRepositoryArgs, opts?: CustomResourceOptions);
@overload
def TeamRepository(resource_name: str,
                   args: TeamRepositoryArgs,
                   opts: Optional[ResourceOptions] = None)

@overload
def TeamRepository(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   repository: Optional[str] = None,
                   team_id: Optional[str] = None,
                   permission: Optional[str] = None)
func NewTeamRepository(ctx *Context, name string, args TeamRepositoryArgs, opts ...ResourceOption) (*TeamRepository, error)
public TeamRepository(string name, TeamRepositoryArgs args, CustomResourceOptions? opts = null)
public TeamRepository(String name, TeamRepositoryArgs args)
public TeamRepository(String name, TeamRepositoryArgs args, CustomResourceOptions options)
type: github:TeamRepository
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. TeamRepositoryArgs
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. TeamRepositoryArgs
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. TeamRepositoryArgs
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. TeamRepositoryArgs
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. TeamRepositoryArgs
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 teamRepositoryResource = new Github.TeamRepository("teamRepositoryResource", new()
{
    Repository = "string",
    TeamId = "string",
    Permission = "string",
});
Copy
example, err := github.NewTeamRepository(ctx, "teamRepositoryResource", &github.TeamRepositoryArgs{
	Repository: pulumi.String("string"),
	TeamId:     pulumi.String("string"),
	Permission: pulumi.String("string"),
})
Copy
var teamRepositoryResource = new TeamRepository("teamRepositoryResource", TeamRepositoryArgs.builder()
    .repository("string")
    .teamId("string")
    .permission("string")
    .build());
Copy
team_repository_resource = github.TeamRepository("teamRepositoryResource",
    repository="string",
    team_id="string",
    permission="string")
Copy
const teamRepositoryResource = new github.TeamRepository("teamRepositoryResource", {
    repository: "string",
    teamId: "string",
    permission: "string",
});
Copy
type: github:TeamRepository
properties:
    permission: string
    repository: string
    teamId: string
Copy

TeamRepository 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 TeamRepository resource accepts the following input properties:

Repository
This property is required.
Changes to this property will trigger replacement.
string
The repository to add to the team.
TeamId
This property is required.
Changes to this property will trigger replacement.
string
The GitHub team id or the GitHub team slug
Permission string
The permissions of team members regarding the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull.
Repository
This property is required.
Changes to this property will trigger replacement.
string
The repository to add to the team.
TeamId
This property is required.
Changes to this property will trigger replacement.
string
The GitHub team id or the GitHub team slug
Permission string
The permissions of team members regarding the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull.
repository
This property is required.
Changes to this property will trigger replacement.
String
The repository to add to the team.
teamId
This property is required.
Changes to this property will trigger replacement.
String
The GitHub team id or the GitHub team slug
permission String
The permissions of team members regarding the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull.
repository
This property is required.
Changes to this property will trigger replacement.
string
The repository to add to the team.
teamId
This property is required.
Changes to this property will trigger replacement.
string
The GitHub team id or the GitHub team slug
permission string
The permissions of team members regarding the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull.
repository
This property is required.
Changes to this property will trigger replacement.
str
The repository to add to the team.
team_id
This property is required.
Changes to this property will trigger replacement.
str
The GitHub team id or the GitHub team slug
permission str
The permissions of team members regarding the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull.
repository
This property is required.
Changes to this property will trigger replacement.
String
The repository to add to the team.
teamId
This property is required.
Changes to this property will trigger replacement.
String
The GitHub team id or the GitHub team slug
permission String
The permissions of team members regarding the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull.

Outputs

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

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

Look up Existing TeamRepository Resource

Get an existing TeamRepository 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?: TeamRepositoryState, opts?: CustomResourceOptions): TeamRepository
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        etag: Optional[str] = None,
        permission: Optional[str] = None,
        repository: Optional[str] = None,
        team_id: Optional[str] = None) -> TeamRepository
func GetTeamRepository(ctx *Context, name string, id IDInput, state *TeamRepositoryState, opts ...ResourceOption) (*TeamRepository, error)
public static TeamRepository Get(string name, Input<string> id, TeamRepositoryState? state, CustomResourceOptions? opts = null)
public static TeamRepository get(String name, Output<String> id, TeamRepositoryState state, CustomResourceOptions options)
resources:  _:    type: github:TeamRepository    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:
Etag string
Permission string
The permissions of team members regarding the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull.
Repository Changes to this property will trigger replacement. string
The repository to add to the team.
TeamId Changes to this property will trigger replacement. string
The GitHub team id or the GitHub team slug
Etag string
Permission string
The permissions of team members regarding the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull.
Repository Changes to this property will trigger replacement. string
The repository to add to the team.
TeamId Changes to this property will trigger replacement. string
The GitHub team id or the GitHub team slug
etag String
permission String
The permissions of team members regarding the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull.
repository Changes to this property will trigger replacement. String
The repository to add to the team.
teamId Changes to this property will trigger replacement. String
The GitHub team id or the GitHub team slug
etag string
permission string
The permissions of team members regarding the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull.
repository Changes to this property will trigger replacement. string
The repository to add to the team.
teamId Changes to this property will trigger replacement. string
The GitHub team id or the GitHub team slug
etag str
permission str
The permissions of team members regarding the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull.
repository Changes to this property will trigger replacement. str
The repository to add to the team.
team_id Changes to this property will trigger replacement. str
The GitHub team id or the GitHub team slug
etag String
permission String
The permissions of team members regarding the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull.
repository Changes to this property will trigger replacement. String
The repository to add to the team.
teamId Changes to this property will trigger replacement. String
The GitHub team id or the GitHub team slug

Import

GitHub Team Repository can be imported using an ID made up of team_id:repository or team_name:repository, e.g.

$ pulumi import github:index/teamRepository:TeamRepository terraform_repo 1234567:terraform
Copy
$ pulumi import github:index/teamRepository:TeamRepository terraform_repo Administrators:terraform
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.