Last active
October 13, 2023 07:30
-
-
Save jorgeancal/ccdbd76aaa2bc7013d85e0ff6c9100bd to your computer and use it in GitHub Desktop.
GitHub Creation of Teams and Add members
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# variables.tf | |
variable "teams" { | |
type = map(object({ | |
description = string | |
members = list(object({ | |
username = string | |
role = string | |
})) | |
})) | |
description = "Map of team names and members" | |
} | |
# github_teams.tf | |
resource "github_team" "teams" { | |
for_each = var.teams | |
name = each.key | |
description = each.value.description | |
privacy = "closed" | |
} | |
# github_teams.tf | |
resource "github_team_members" "observability_members" { | |
for_each = var.teams | |
team_id = github_team.teams[each.key].id | |
dynamic "members" { | |
for_each = var.teams[each.key].members | |
content { | |
username = members.value.username | |
role = members.value.role | |
} | |
} | |
} | |
# variables.tfvars | |
teams = { | |
team-1 = { | |
description = "Team 1 Description" | |
members = [ | |
{ | |
username = "jorgeancal" | |
role = "member" | |
} | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment