Skip to content

Latest commit

 

History

59 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Module: Github

A Terraform module for admin GitHub Account/Organization

These types of resources are supported:

Requirements

Name Version
terraform >= 0.13.0
aws ~> 3.0

Providers

Name Version
Github ~> 4.0.0

Features

Members Management

  • Add member to the GitHub Account/Organization
  • Asign member to Team

Repositories Management

  • Create Repositorie
  • Define default branchs
  • Define branch protection and restrictions.

Teams Management

  • Create teams
  • Add teams to repositories

Usage

github-membership:

module "members" {
  source      = "github.com/FlexibilitySRL/terraform-github/modules/github-member"

  admins      = [ "maintainer", "admin-company" ]
  commons     = [ "developer", "customer", "tester", "ops" ]
}

github-team:

module "parent_teams" {
  source      = "github.com/FlexibilitySRL/terraform-github/modules/github-team"
  name        = "Implementation"
  description = "This is the description of the team" 
  members     = [ "customer" ]
  maintainers = [ "maintainer" ]
}

module "child_teams" {
  source          = "github.com/FlexibilitySRL/terraform-github/modules/github-team"

  name            = "Developer team"
  parent_team_id  = module.parent_teams["Implementation"].id
  members         = [ "developer", "tester" ]
  maintainers     = [ "maintainer" ]

  depends_on = [
    module.parent_teams
  ]
}

github-repository:

module "repositories" {
  source      = "github.com/FlexibilitySRL/terraform-github/modules/github-repository"

  name                = "Repository name"
  description         = "Repository description"
  visibility          = "public"

  branchs             = [ "master" , "develop" ] 
  protection_branchs  = {
      master = {
          required_approving_review_count = 2,
          restrictions_teams = [ "ops", "maintainer" ]
        },
      release = {
          required_approving_review_count = 1,
          restrictions_teams = [ "ops" ]
        }
   }
}

github-team-repository:

module "team_repository" {
  source      = "github.com/FlexibilitySRL/terraform-github/modules/github-team-repository"

  team_id     = module.parent_teams["implementation"].id
  admins      = [ "maintainer" ]
  pushs       = [ "developer" ]
  pulls       = [ "tester" ]
  maintainers = [ "maintainer" ]
}

NOTE: In order to use the GitHub module it's necessary to config the Terraform GitHub Provider:

#=============================#
# GITHUB Provider Settings    #
#=============================#
provider "github" {
  token        = [GITHUB_ACCESS_TOKEN]
  organization = [GITHUB_ORGANIZATION]
  version = "~> 3.0.0"
}

1. Add Github Members

Use github-membership module module to add github members to company.

2. Create Teams and add Members

Use github-team module module to create Teams and add members and maintainers.

3. Create Repositories, branches and branch protection

Use github-repository module module to create one or many repositories and create its branches and protect or not that branches.

4. Add a relation between Teams and Repositories

Use github-team-repository module module to add a relationship between repositories and teams.

Examples

Authors

Module managed by Flexibility.

License

MIT License. See LICENSE for full details.

About

Terraform module which creates GitHub resources

Resources

Stars

1 star

Watchers

4 watching

Forks

Releases

Packages

Contributors

Languages