Managing GitHub with Terraform
There're many service providers to use with Terraform. GitHub is one of them, and we'll see how to manage members of an organization, various teams, and control repository access, right from our infrastructure code. That way, we have an automatic history log of who accesses what.
Getting ready
To step through this recipe, you will need the following:
A working Terraform installation
A GitHub account (with an API token)
An Internet connection
How to do it…
We want to manage a GitHub organization named ACME. Here are the users and their groups:
GitHub username |
GitHub team name |
Membership level |
Team privacy |
---|---|---|---|
John |
Documentation |
member |
closed |
Jane |
Engineering |
admin |
secret |
Here's the policy we decided concerning the Git repository named infrastructure-repository
:
GitHub team name |
Repository permissions |
---|---|
Documentation |
pull |
Engineering |
admin |
Configuring GitHub
Let's start by creating a github
provider, as we used an aws
provider for AWS in the previous recipes...