Hello! I have the code
module "github_team" {
source = "../../modules/github-team"
name = "tr-${local.name}"
description = "Custom role for team ${local.name} "
users = { for each in var.members : local.iam_users[each].github_account => "member" if local.iam_users[each].github_account != "" }
repositories = var.github_repositories
}
When i merge 2 account without github account, then i get error “Error: Duplicate object key”
Two different items produced the key " # doesn't have github account" in this
'for' expression. If duplicates are expected, use the ellipsis (...) after
the value expression to enable grouping by key.
I try rewrite code:
module "github_team" {
foreach = length(var.github_repositories) > 0 ? { enabled = true } : {}
source = "../../modules/github-team"
name = "tr-${local.name}"
description = "Custom role for team ${local.name} "
users = { for each in var.members : local.iam_users[each].github_account => "member" if local.iam_users[each].github_account != "" }
repositories = var.github_repositories
}
moved {
from = module.github_team
to = module.github_team["enabled"]
}
But error
Error: Unsupported argument
on z-shared-iam-team-main.tf line 94, in module "github_team":
94: foreach = length(var.github_repositories) > 0 ? { enabled = true } :
An argument named "foreach" is not expected here.