If you want to manage user and teams in github through terraform, this is the repo for you.
This repo makes use of the Github Terraform Provider https://registry.terraform.io/providers/integrations/github/latest/docs
Things you will need to setup:
- Github Org
- Github App - create it, install it in the org, create a private key
- Terraform cloud or local state
- Add your github org name to vars.tfvars
- Create a Github App at https://github.com/organizations/{org}/settings/apps/new
- Give https://app.terraform.io as Homepage if using terraform cloud
- uncheck webhook
- select Org permissions > Members > Read and Write
- Only this account and apply
- Take note of the App ID and add it to the vars.tfvars file
- Go to private keys and generate a private key and store it in github-app-private-key.pem file
- Go to Install app and install it in your org
- Take a note of the Installtion ID in the URL https://github.com/organizations/{org}/settings/installations/{THIS_ID} and put it in vars.tfvars
- Add your org name and workspace id to providers.tf
- Run
terraform init
terraform validate
terraform plan --var-file vars.tfvars
terraform apply --var-file vars.tfvars
Note: the users that you add to your org will need to accept the invite before they appear in any teams.