From edea1e619578bc8f8fb5fbd92cef2e21824e6c0f Mon Sep 17 00:00:00 2001 From: Tyler Mizuyabu Date: Mon, 4 Mar 2024 15:48:37 -0500 Subject: [PATCH 1/3] exposing parent id as a variable --- modules/team/team.tf | 11 ++++++----- modules/team/variables.tf | 8 +++++++- modules/team_set/teams.tf | 2 ++ modules/team_set/variables.tf | 1 + 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/team/team.tf b/modules/team/team.tf index 8803f4a..b9b1b54 100644 --- a/modules/team/team.tf +++ b/modules/team/team.tf @@ -3,8 +3,9 @@ locals { } resource "github_team" "team" { - count = local.create_team ? 1 : 0 - name = var.team_name - description = var.team_description - privacy = var.privacy -} \ No newline at end of file + count = local.create_team ? 1 : 0 + name = var.team_name + description = var.team_description + privacy = var.privacy + parent_team_id = var.parent_id +} diff --git a/modules/team/variables.tf b/modules/team/variables.tf index d8a9264..5e47fb9 100644 --- a/modules/team/variables.tf +++ b/modules/team/variables.tf @@ -34,4 +34,10 @@ variable "team_id" { type = string description = "The ID of the team if it exists (optional)." default = "" -} \ No newline at end of file +} + +variable "parent_id" { + type = string + description = "The ID of the parent team if it exists (optional)." + default = "" +} diff --git a/modules/team_set/teams.tf b/modules/team_set/teams.tf index 27aaa7a..a147f21 100644 --- a/modules/team_set/teams.tf +++ b/modules/team_set/teams.tf @@ -7,6 +7,7 @@ module "team" { team_members = each.value.members team_description = each.value.description privacy = each.value.privacy + parent_id = each.value.parent_id team_name = each.key } @@ -18,5 +19,6 @@ module "prexisting_team" { team_maintainers = each.value.maintainers team_members = each.value.members + parent_id = data.terraform_remote_state.state[local.team_to_state_index_map[each.key]].outputs["parent_team_id"] team_name = each.key } diff --git a/modules/team_set/variables.tf b/modules/team_set/variables.tf index 40abc57..318ef52 100644 --- a/modules/team_set/variables.tf +++ b/modules/team_set/variables.tf @@ -4,6 +4,7 @@ variable "teams" { privacy = string maintainers = list(string) members = list(string) + parent_id = string })) description = "A map of teams to create where the key is the team name and the value is the configuration" } From fe5c06325834816cf3a0a64c2d12116cf7ca3a9b Mon Sep 17 00:00:00 2001 From: Tyler Mizuyabu Date: Mon, 4 Mar 2024 15:56:47 -0500 Subject: [PATCH 2/3] change data reference to variable reference --- modules/team_set/teams.tf | 2 +- modules/team_set/variables.tf | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/team_set/teams.tf b/modules/team_set/teams.tf index a147f21..498d3b8 100644 --- a/modules/team_set/teams.tf +++ b/modules/team_set/teams.tf @@ -19,6 +19,6 @@ module "prexisting_team" { team_maintainers = each.value.maintainers team_members = each.value.members - parent_id = data.terraform_remote_state.state[local.team_to_state_index_map[each.key]].outputs["parent_team_id"] + parent_id = each.value.parent_id team_name = each.key } diff --git a/modules/team_set/variables.tf b/modules/team_set/variables.tf index 318ef52..1bff325 100644 --- a/modules/team_set/variables.tf +++ b/modules/team_set/variables.tf @@ -6,7 +6,7 @@ variable "teams" { members = list(string) parent_id = string })) - description = "A map of teams to create where the key is the team name and the value is the configuration" + description = "A map of teams to create where the key is the team name and the value is the configuration. If the team does not have a parent team, the parent_id should be an empty string." } variable "preexisting_teams" { @@ -16,7 +16,8 @@ variable "preexisting_teams" { output_name = string maintainers = list(string) members = list(string) + parent_id = string })) - description = "A map of existing teams where the key is the team name and the value is the configuration" + description = "A map of existing teams where the key is the team name and the value is the configuration. If the team does not have a parent team, the parent_id should be an empty string." default = {} } From 3119d8fb796f38159c66feadd7bc74afda86f050 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 4 Mar 2024 20:59:26 +0000 Subject: [PATCH 3/3] terraform-docs: automated action --- modules/team/README.md | 1 + modules/team_set/README.md | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/team/README.md b/modules/team/README.md index 884bb1f..ff3387c 100644 --- a/modules/team/README.md +++ b/modules/team/README.md @@ -27,6 +27,7 @@ No modules. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| +| [parent\_id](#input\_parent\_id) | The ID of the parent team if it exists (optional). | `string` | `""` | no | | [privacy](#input\_privacy) | The privacy setting for the github team. Must be one of `closed` or `secret`. | `string` | `"closed"` | no | | [team\_description](#input\_team\_description) | Description of the github team to be created. | `string` | `""` | no | | [team\_id](#input\_team\_id) | The ID of the team if it exists (optional). | `string` | `""` | no | diff --git a/modules/team_set/README.md b/modules/team_set/README.md index 1a8243a..e209b1f 100644 --- a/modules/team_set/README.md +++ b/modules/team_set/README.md @@ -28,8 +28,8 @@ | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| [preexisting\_teams](#input\_preexisting\_teams) | A map of existing teams where the key is the team name and the value is the configuration |
map(object({
bucket = string
prefix = string
output_name = string
maintainers = list(string)
members = list(string)
}))
| `{}` | no | -| [teams](#input\_teams) | A map of teams to create where the key is the team name and the value is the configuration |
map(object({
description = string
privacy = string
maintainers = list(string)
members = list(string)
}))
| n/a | yes | +| [preexisting\_teams](#input\_preexisting\_teams) | A map of existing teams where the key is the team name and the value is the configuration. If the team does not have a parent team, the parent\_id should be an empty string. |
map(object({
bucket = string
prefix = string
output_name = string
maintainers = list(string)
members = list(string)
parent_id = string
}))
| `{}` | no | +| [teams](#input\_teams) | A map of teams to create where the key is the team name and the value is the configuration. If the team does not have a parent team, the parent\_id should be an empty string. |
map(object({
description = string
privacy = string
maintainers = list(string)
members = list(string)
parent_id = string
}))
| n/a | yes | ## Outputs