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
+ # ---------------------------------------------------------------------------------------------------------------------
1
11
terraform {
2
- required_version = " ~> 0.12.9"
3
- }
12
+ required_version = " >= 0.12.9"
4
13
5
- provider "github" {
6
- version = " >= 2.3.1, < 3.0.0"
14
+ required_providers {
15
+ github = " >= 2.3.1, < 3.0.0"
16
+ }
7
17
}
8
18
19
+
9
20
module "repository" {
10
21
source = " ../.."
11
22
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
15
26
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
24
35
gitignore_template = " Terraform"
25
36
license_template = " mit"
26
37
archived = false
@@ -43,37 +54,37 @@ module "repository" {
43
54
44
55
required_pull_request_reviews = {
45
56
dismiss_stale_reviews = true
46
- dismissal_users = [ " terraform-test-user-1 " ]
57
+ dismissal_users = var.members
47
58
dismissal_teams = [github_team.team.slug]
48
59
require_code_owner_reviews = true
49
60
required_approving_review_count = 1
50
61
}
51
62
52
63
restrictions = {
53
- users = [ " terraform-test-user-1 " ]
54
- teams = [" team-1 " ]
64
+ users = var.members
65
+ teams = [github_team. team.slug ]
55
66
}
56
67
}
57
68
]
58
69
}
59
70
60
71
resource "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
63
74
privacy = " secret"
64
75
}
65
76
66
77
# ---------------------------------------------------------------------------------------------------------------------
67
78
# 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 .
71
82
# ---------------------------------------------------------------------------------------------------------------------
72
83
73
84
resource "github_team_membership" "team_membership" {
74
- count = 2
85
+ count = length (var . members )
75
86
76
87
team_id = github_team. team . id
77
- username = " terraform-test-user- ${ count . index } "
88
+ username = var . members [ count . index ]
78
89
role = " member"
79
90
}
0 commit comments