1+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2+ # CREATE A PRIVATE REPOSITORY WITH AN ATTACHED TEAM
3+ # - create a private repository
4+ # - create a team and invite members
5+ # - add the team to the repository and grant admin permissions
6+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7+
8+ # ---------------------------------------------------------------------------------------------------------------------
9+ # SET TERRAFORM AND PROVIDER REQUIREMENTS FOR RUNNING THIS MODULE
10+ # ---------------------------------------------------------------------------------------------------------------------
111terraform {
2- required_version = " ~> 0.12.9"
3- }
12+ required_version = " >= 0.12.9"
413
5- provider "github" {
6- version = " >= 2.3.1, < 3.0.0"
14+ required_providers {
15+ github = " >= 2.3.1, < 3.0.0"
16+ }
717}
818
19+
920module "repository" {
1021 source = " ../.."
1122
12- name = " private-repository-with-teams "
13- description = " A private repository created with terraform to test the terraform-github-repository module. "
14- homepage_url = " https://github.com/mineiros-io "
23+ name = var . name
24+ description = var . description
25+ homepage_url = var . homepage_url
1526 private = true
16- has_issues = true
17- has_projects = true
18- has_wiki = true
19- allow_merge_commit = true
20- allow_rebase_merge = true
21- allow_squash_merge = true
22- has_downloads = false
23- auto_init = true
27+ has_issues = var . has_issues
28+ has_projects = var . has_projects
29+ has_wiki = var . has_wiki
30+ allow_merge_commit = var . allow_merge_commit
31+ allow_rebase_merge = var . allow_rebase_merge
32+ allow_squash_merge = var . allow_squash_merge
33+ has_downloads = var . has_downloads
34+ auto_init = var . auto_init
2435 gitignore_template = " Terraform"
2536 license_template = " mit"
2637 archived = false
@@ -43,37 +54,37 @@ module "repository" {
4354
4455 required_pull_request_reviews = {
4556 dismiss_stale_reviews = true
46- dismissal_users = [ " terraform-test-user-1 " ]
57+ dismissal_users = var.members
4758 dismissal_teams = [github_team.team.slug]
4859 require_code_owner_reviews = true
4960 required_approving_review_count = 1
5061 }
5162
5263 restrictions = {
53- users = [ " terraform-test-user-1 " ]
54- teams = [" team-1 " ]
64+ users = var.members
65+ teams = [github_team. team.slug ]
5566 }
5667 }
5768 ]
5869}
5970
6071resource "github_team" "team" {
61- name = " private-repository-with-teams-test-team "
62- description = " This team is created with terraform to test the terraformn-github-repository module. "
72+ name = var . team_name
73+ description = var . team_description
6374 privacy = " secret"
6475}
6576
6677# ---------------------------------------------------------------------------------------------------------------------
6778# TEAM MEMBERSHIP
68- # We are adding two members to this team. terraform-test-user-1 and terraform-test-user-2 which are both existing users
69- # and already members of the GitHub Organization terraform-test that is an Organization managed by Mineiros.io to run
70- # integration tests with Terragrunt .
79+ # We are adding two members to this team. terraform-test-user-1 and terraform-test-user-2 that we define as default
80+ # members in our variables.tf are both existing users and already members of the GitHub Organization terraform-test that
81+ # is an Organization managed by Mineiros.io to run integration tests with Terratest .
7182# ---------------------------------------------------------------------------------------------------------------------
7283
7384resource "github_team_membership" "team_membership" {
74- count = 2
85+ count = length (var . members )
7586
7687 team_id = github_team. team . id
77- username = " terraform-test-user- ${ count . index } "
88+ username = var . members [ count . index ]
7889 role = " member"
7990}
0 commit comments