Skip to content

Instantly share code, notes, and snippets.

@jorgeancal
Last active October 13, 2023 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgeancal/ccdbd76aaa2bc7013d85e0ff6c9100bd to your computer and use it in GitHub Desktop.
Save jorgeancal/ccdbd76aaa2bc7013d85e0ff6c9100bd to your computer and use it in GitHub Desktop.
GitHub Creation of Teams and Add members
# 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