Last active
March 23, 2016 14:23
-
-
Save JacobASeverson/7968fffa82ba45783b96 to your computer and use it in GitHub Desktop.
Example of managing a Github organization with Terraform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
## <1> The two properties that need to be set are `token` and `organization`. You can hardcode them right in | |
## this provider block (very unrecommended) but the better option is to set the `GITHUB_TOKEN` | |
## and `GITHUB_ORGANIZATION` environment variables. Terraform will see those and configure the provider with them. | |
### | |
provider "github" { } | |
### | |
## <2> This assigns a user to the organization. the `username` property should be their string username. | |
### | |
resource "github_membership" "test_user_membership" { | |
username = "TestUser" | |
role = "member" | |
} | |
### | |
## <3> This will create and manage a new team within the organization. | |
### | |
resource "github_team" "test_team" { | |
name = "test-team" | |
description = "A new team created with Terraform." | |
} | |
### | |
## <4> Assigns a user to a team. You can interpolate the team's id with the syntax below. | |
## For the `username` you again use the actual string username for the user. | |
### | |
resource "github_team_membership" "test_user_test_team" { | |
team_id = "${github_team.test_team.id}" | |
username = "TestUser" | |
role = "member" | |
} | |
### | |
## <5> Assigns an existing Github repository to the created team. For `repository`, use the actual string name | |
## of the repository. | |
### | |
resource "github_team_repository" "test_team_test_repo" { | |
team_id = "${github_team.test_team.id}" | |
repository = "existing-repo-name" | |
permission = "pull" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment