I have made (manualy) in github a team called Land and assigned 2 users to this team.
data "github_team" "Land" {
slug = "my-land"
}
Then, I created trough terrform, 2 new tams called A1-team and A2-team.
locals {
team_descriptions = {for name in var.team-names : name => format(var.team_description_template, name)}
}
resource "github_team" "managed_team" {
for_each = var.team-names
name = each.value
description = local.team_descriptions[each.key]
privacy = "closed"
}
variable "team-names" {
type = set(string)
default = ["A1-team", "A2-team"]
}
Changes to Outputs:
+ gh-land-team = [
+ {
+ A1-team = {
+ create_default_maintainer = false
+ description = "A1-team is part of my-land"
+ etag = (known after apply)
+ id = (known after apply)
+ ldap_dn = null
+ members_count = (known after apply)
+ name = "A1-team"
+ node_id = (known after apply)
+ parent_team_id = null
+ privacy = "closed"
+ slug = (known after apply)
}
+ A2-team = {
+ create_default_maintainer = false
+ description = "A2-team is part of my-land"
+ etag = (known after apply)
+ id = (known after apply)
+ ldap_dn = null
+ members_count = (known after apply)
+ name = "A2-team"
+ node_id = (known after apply)
+ parent_team_id = null
+ privacy = "closed"
+ slug = (known after apply)
}
},
]
+ members = [
+ "user1",
+ "user2",
]
My problem is when trying to assing the users of team “Land” to the newly created teams A1-team and A2-team. I want teams A1 and A2 to have the same users as Land team (user1 and user2).
locals {
team_ids = [for team_name in var.team-names : github_team.managed_team["${team_name}"].id]
}
resource "github_team_membership" "memberships" {
for_each = toset(data.github_team.Land.members)
team_id = "${local.team_ids}"
username = each.value
}
│ Error: Incorrect attribute value type
│
│ on 1-Land.tf line 67, in resource "github_team_membership" "memberships":
│ 67: team_id = "${local.team_ids}"
│ ├────────────────
│ │ local.team_ids is tuple with 2 elements
│
│ Inappropriate value for attribute "team_id": string required.
╵
╷
│ Error: Incorrect attribute value type
│
│ on 1-Land.tf line 67, in resource "github_team_membership" "memberships":
│ 67: team_id = "${local.team_ids}"
│ ├────────────────
│ │ local.team_ids is tuple with 2 elements
│
│ Inappropriate value for attribute "team_id": string required.