I Want to add the users to the team and assigned them roles as per the yaml but the error is value does not have any attributes. i will have multiple users in single team with different roles
this is variables.tf
variable "admin_role_id" {
description = "The id to give access admin role to the user"
type = string
default = "1111111111111"
}
variable "user_role_id" {
description = "The id to give access user role to the user"
type = string
default = "22222222222222222"
}
this is my yaml file
TEAM1:
- users:
- joe@gmail.com
- pa@gmail.com
roles:
- ${user_role}
- ${admin_role}
- users:
- test@gmail.com
roles:
- ${user_role}
TEAM2:
- users:
- joe@gmail.com
roles:
- ${test_user_role}
This is TERRAFORM CODE i am using local variable and i flatten the values there
locals {
render_membership = templatefile("${path.module}/teammembers.yaml",
{
admin_role = var.admin_role_id
user_role = var.user_role_id
}
)
membership_nested = yamldecode(local.render_membership)
membership_flat = flatten(
[
for team_key, team in local.membership_nested : [
for user in team.users : {
team_name = team_key
user_name = user
roles = team.roles
}
]
]
)
}
resource "squadcast_team_member" "membership" {
for_each = { for i, v in local.membership_flat : i => v }
team_id = data.squadcast_team.teams[each.value.team_name].id
user_id = data.squadcast_user.users[each.value.user_name].id
role_ids = each.value.roles
}
data "squadcast_team" "teams" {
for_each = { for i, v in local.membership_flat : i => v }
name = each.value.team_name
}
data "squadcast_user" "users" {
for_each = { for i, v in local.membership_flat : i => v }
email = each.value.user_name
}
output "rendered_yaml" {
value = local.membership_nested
}
Error:
│ Error: Unsupported attribute
│
│ on teammembers.tf line 112, in locals:
│ 112: for user in team.users : {
│
│ This value does not have any attributes.