Skip to content

Commit 8130794

Browse files
committed
Migrate modules
1 parent cfc8309 commit 8130794

29 files changed

+1407
-0
lines changed

modules/org-organization/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# org-organization
2+
3+
This module creates following resources.
4+
5+
- `github_membership` (optional)
6+
- `github_organization_block` (optional)
7+
8+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
9+
## Requirements
10+
11+
| Name | Version |
12+
|------|---------|
13+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.1 |
14+
| <a name="requirement_github"></a> [github](#requirement\_github) | = 4.13.0 |
15+
16+
## Providers
17+
18+
| Name | Version |
19+
|------|---------|
20+
| <a name="provider_github"></a> [github](#provider\_github) | 4.13.0 |
21+
22+
## Modules
23+
24+
No modules.
25+
26+
## Resources
27+
28+
| Name | Type |
29+
|------|------|
30+
| [github_membership.this](https://registry.terraform.io/providers/hashicorp/github/4.13.0/docs/resources/membership) | resource |
31+
| [github_organization_block.this](https://registry.terraform.io/providers/hashicorp/github/4.13.0/docs/resources/organization_block) | resource |
32+
| [github_organization.after](https://registry.terraform.io/providers/hashicorp/github/4.13.0/docs/data-sources/organization) | data source |
33+
| [github_organization.this](https://registry.terraform.io/providers/hashicorp/github/4.13.0/docs/data-sources/organization) | data source |
34+
35+
## Inputs
36+
37+
| Name | Description | Type | Default | Required |
38+
|------|-------------|------|---------|:--------:|
39+
| <a name="input_name"></a> [name](#input\_name) | (Required) The name of the organization. | `string` | n/a | yes |
40+
| <a name="input_blocked_users"></a> [blocked\_users](#input\_blocked\_users) | (Optional) A list of usernames to block from organization. | `set(string)` | `[]` | no |
41+
| <a name="input_members"></a> [members](#input\_members) | (Optional) A list of usernames to add users as `member` role. When applied, an invitation will be sent to the user to become a member of the organization. | `set(string)` | `[]` | no |
42+
| <a name="input_owners"></a> [owners](#input\_owners) | (Optional) A list of usernames to add users as `admin` role. When applied, an invitation will be sent to the user to become an owner of the organization. | `set(string)` | `[]` | no |
43+
44+
## Outputs
45+
46+
| Name | Description |
47+
|------|-------------|
48+
| <a name="output_all_members"></a> [all\_members](#output\_all\_members) | A list of all members of the organization. |
49+
| <a name="output_blocked_users"></a> [blocked\_users](#output\_blocked\_users) | A list of blocked usernames from organization. |
50+
| <a name="output_description"></a> [description](#output\_description) | The description of the organization. |
51+
| <a name="output_display_name"></a> [display\_name](#output\_display\_name) | The display name of the organization. |
52+
| <a name="output_id"></a> [id](#output\_id) | The ID of the organization. |
53+
| <a name="output_members"></a> [members](#output\_members) | A list of the members of the organization. |
54+
| <a name="output_name"></a> [name](#output\_name) | The name of the organization. |
55+
| <a name="output_owners"></a> [owners](#output\_owners) | A list of the owners of the organization. |
56+
| <a name="output_plan"></a> [plan](#output\_plan) | The billing plan of the organization. |
57+
| <a name="output_repositories"></a> [repositories](#output\_repositories) | A list of the repositories of the organization. |
58+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

modules/org-organization/main.tf

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
data "github_organization" "this" {
2+
name = var.name
3+
}
4+
5+
data "github_organization" "after" {
6+
name = var.name
7+
8+
depends_on = [
9+
github_membership.this
10+
]
11+
}
12+
13+
locals {
14+
members = [
15+
for member in var.members : {
16+
username = member
17+
role = "member"
18+
}
19+
]
20+
owners = [
21+
for owner in var.owners : {
22+
username = owner
23+
role = "admin"
24+
}
25+
]
26+
membership = concat(local.members, local.owners)
27+
}
28+
29+
30+
###################################################
31+
# Membership of GitHub Organization
32+
###################################################
33+
34+
resource "github_membership" "this" {
35+
for_each = {
36+
for member in local.membership :
37+
member.username => member
38+
}
39+
40+
username = each.key
41+
role = each.value.role
42+
}
43+
44+
45+
###################################################
46+
# Blocked Users of GitHub Organization
47+
###################################################
48+
49+
resource "github_organization_block" "this" {
50+
for_each = toset(var.blocked_users)
51+
52+
username = each.key
53+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
output "name" {
2+
description = "The name of the organization."
3+
value = data.github_organization.this.login
4+
}
5+
6+
output "display_name" {
7+
description = "The display name of the organization."
8+
value = data.github_organization.this.name
9+
}
10+
11+
output "id" {
12+
description = "The ID of the organization."
13+
value = data.github_organization.this.id
14+
}
15+
16+
output "description" {
17+
description = "The description of the organization."
18+
value = data.github_organization.this.description
19+
}
20+
21+
output "plan" {
22+
description = "The billing plan of the organization."
23+
value = data.github_organization.this.plan
24+
}
25+
26+
output "owners" {
27+
description = "A list of the owners of the organization."
28+
value = var.owners
29+
}
30+
31+
output "members" {
32+
description = "A list of the members of the organization."
33+
value = var.members
34+
}
35+
36+
output "all_members" {
37+
description = "A list of all members of the organization."
38+
value = data.github_organization.after.members
39+
}
40+
41+
output "repositories" {
42+
description = "A list of the repositories of the organization."
43+
value = data.github_organization.this.repositories
44+
}
45+
46+
output "blocked_users" {
47+
description = "A list of blocked usernames from organization."
48+
value = var.blocked_users
49+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
variable "name" {
2+
description = "(Required) The name of the organization."
3+
type = string
4+
}
5+
6+
variable "owners" {
7+
description = "(Optional) A list of usernames to add users as `admin` role. When applied, an invitation will be sent to the user to become an owner of the organization."
8+
type = set(string)
9+
default = []
10+
}
11+
12+
variable "members" {
13+
description = "(Optional) A list of usernames to add users as `member` role. When applied, an invitation will be sent to the user to become a member of the organization."
14+
type = set(string)
15+
default = []
16+
}
17+
18+
variable "blocked_users" {
19+
description = "(Optional) A list of usernames to block from organization."
20+
type = set(string)
21+
default = []
22+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
terraform {
2+
required_version = ">= 1.1"
3+
4+
required_providers {
5+
github = {
6+
# source = "integrations/github"
7+
# version = ">= 4.19"
8+
source = "hashicorp/github"
9+
version = "= 4.13.0"
10+
}
11+
}
12+
}

modules/org-team/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# org-team
2+
3+
This module creates following resources.
4+
5+
- `github_team`
6+
- `github_team_membership` (optional)
7+
8+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
9+
## Requirements
10+
11+
| Name | Version |
12+
|------|---------|
13+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.1 |
14+
| <a name="requirement_github"></a> [github](#requirement\_github) | = 4.13.0 |
15+
16+
## Providers
17+
18+
| Name | Version |
19+
|------|---------|
20+
| <a name="provider_github"></a> [github](#provider\_github) | 4.13.0 |
21+
22+
## Modules
23+
24+
No modules.
25+
26+
## Resources
27+
28+
| Name | Type |
29+
|------|------|
30+
| [github_team.this](https://registry.terraform.io/providers/hashicorp/github/4.13.0/docs/resources/team) | resource |
31+
| [github_team_membership.this](https://registry.terraform.io/providers/hashicorp/github/4.13.0/docs/resources/team_membership) | resource |
32+
33+
## Inputs
34+
35+
| Name | Description | Type | Default | Required |
36+
|------|-------------|------|---------|:--------:|
37+
| <a name="input_name"></a> [name](#input\_name) | (Required) The name of the team. | `string` | n/a | yes |
38+
| <a name="input_default_maintainer_enabled"></a> [default\_maintainer\_enabled](#input\_default\_maintainer\_enabled) | (Optional) If true, adds the creating user as a default maintainer to the team. | `bool` | `false` | no |
39+
| <a name="input_description"></a> [description](#input\_description) | (Optional) A description of the team. | `string` | `"Managed by Terraform."` | no |
40+
| <a name="input_is_secret"></a> [is\_secret](#input\_is\_secret) | (Optional) If true, team is only visible to the people on the team and people with owner permissions. | `bool` | `false` | no |
41+
| <a name="input_ldap_group_dn"></a> [ldap\_group\_dn](#input\_ldap\_group\_dn) | (Optional) The LDAP Distinguished Name of the group where membership will be synchronized. Only available in GitHub Enterprise Server. | `string` | `null` | no |
42+
| <a name="input_maintainers"></a> [maintainers](#input\_maintainers) | (Optional) A list of usernames to add users as `maintainer` role. When applied, the user will become a maintainer of the team. | `set(string)` | `[]` | no |
43+
| <a name="input_members"></a> [members](#input\_members) | (Optional) A list of usernames to add users as `member` role. When applied, the user will become a member of the team. | `set(string)` | `[]` | no |
44+
| <a name="input_parent_id"></a> [parent\_id](#input\_parent\_id) | (Optional) The ID of the parent team, if this is a nested team. | `string` | `null` | no |
45+
46+
## Outputs
47+
48+
| Name | Description |
49+
|------|-------------|
50+
| <a name="output_default_maintainer_enabled"></a> [default\_maintainer\_enabled](#output\_default\_maintainer\_enabled) | Whether to add the creating user as a default maintainer. |
51+
| <a name="output_description"></a> [description](#output\_description) | The description of the team. |
52+
| <a name="output_id"></a> [id](#output\_id) | The ID of the team. |
53+
| <a name="output_is_secret"></a> [is\_secret](#output\_is\_secret) | Whether to be only visible to the people on the team and people with owner permissions. |
54+
| <a name="output_ldap_group_dn"></a> [ldap\_group\_dn](#output\_ldap\_group\_dn) | The LDAP Distinguished Name of the group where membership will be synchronized. |
55+
| <a name="output_maintainers"></a> [maintainers](#output\_maintainers) | A list of the maintainers of the team. |
56+
| <a name="output_members"></a> [members](#output\_members) | A list of the members of the team. |
57+
| <a name="output_name"></a> [name](#output\_name) | The name of the team. |
58+
| <a name="output_node_id"></a> [node\_id](#output\_node\_id) | The Node ID of the team. |
59+
| <a name="output_parent_id"></a> [parent\_id](#output\_parent\_id) | The ID of the parent team. |
60+
| <a name="output_slug"></a> [slug](#output\_slug) | The slug of the team. |
61+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

modules/org-team/main.tf

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
resource "github_team" "this" {
2+
name = var.name
3+
description = try(var.description, null)
4+
privacy = var.is_secret ? "secret" : "closed"
5+
6+
parent_team_id = try(var.parent_id, null)
7+
create_default_maintainer = var.default_maintainer_enabled
8+
9+
ldap_dn = try(var.ldap_group_dn, null)
10+
}
11+
12+
locals {
13+
members = [
14+
for member in var.members : {
15+
username = member
16+
role = "member"
17+
}
18+
]
19+
maintainers = [
20+
for maintainer in var.maintainers : {
21+
username = maintainer
22+
role = "maintainer"
23+
}
24+
]
25+
membership = concat(local.members, local.maintainers)
26+
}
27+
28+
29+
###################################################
30+
# Membership of GitHub Organization Team
31+
###################################################
32+
33+
resource "github_team_membership" "this" {
34+
for_each = {
35+
for member in local.membership :
36+
member.username => member
37+
}
38+
39+
team_id = github_team.this.id
40+
username = each.key
41+
role = each.value.role
42+
}

modules/org-team/outputs.tf

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
output "id" {
2+
description = "The ID of the team."
3+
value = github_team.this.id
4+
}
5+
6+
output "node_id" {
7+
description = "The Node ID of the team."
8+
value = github_team.this.node_id
9+
}
10+
11+
output "slug" {
12+
description = "The slug of the team."
13+
value = github_team.this.slug
14+
}
15+
16+
output "name" {
17+
description = "The name of the team."
18+
value = github_team.this.name
19+
}
20+
21+
output "description" {
22+
description = "The description of the team."
23+
value = github_team.this.description
24+
}
25+
26+
output "is_secret" {
27+
description = "Whether to be only visible to the people on the team and people with owner permissions."
28+
value = var.is_secret
29+
}
30+
31+
output "parent_id" {
32+
description = "The ID of the parent team."
33+
value = github_team.this.parent_team_id
34+
}
35+
36+
output "ldap_group_dn" {
37+
description = "The LDAP Distinguished Name of the group where membership will be synchronized."
38+
value = var.ldap_group_dn
39+
}
40+
41+
output "default_maintainer_enabled" {
42+
description = "Whether to add the creating user as a default maintainer."
43+
value = github_team.this.create_default_maintainer
44+
}
45+
46+
output "maintainers" {
47+
description = "A list of the maintainers of the team."
48+
value = var.maintainers
49+
}
50+
51+
output "members" {
52+
description = "A list of the members of the team."
53+
value = var.members
54+
}

0 commit comments

Comments
 (0)