Hi there, I’m trying to do something a bit aggravating and heavy apologies but the below syntax isn’t correct but hopefully will show the story of what I’m trying to do.
Everything is up for change really so if there’s a better way to put my tfvars, that’s fine.
I’m trying to basically have a group with members in Azure DevOps via tf.
So tfvars like the below.
There’s a snag though in that the Groups and Group Membership resource needs a descriptor. A unique id that AzDo gives the object.
This means I need to first loop those members through a data block, then bring it to the group , while still keeping the group name and the members descriptor linked in.
so , loop the 2 groups in data "azuredevops_users, get the descriptors for the members, then loop the two groups plus the descriptors instead of the member emails, into the azuredevops_group resource so that it makes two groups, with that membership.
Hopefully that’s clear and hopefully one of you boffins can help me. Thank you for your time!
tfvars
groups = [{
groupname = "1209"
members = [
"Step.Baa@email.com",
"Aa.Ban@email.com",
"hael.l@email.com",
"Dl.Ban@email.com",
]
},{
groupname = "1709"
members = [
"gl.ol@email.com",
"ls.g@email.com",
]
},
]
data "azuredevops_users" "group" {
foreach {group in var.groups}
principal_name = each.value.members #this needs to loop each member.
# this data source only takes a single string, not a list
}
resource "azuredevops_group" "group" {
foreach {group in var.groups}
display_name = "testgroup ${each.value.groupname}"
members = flatten(data.azuredevops_users.group[group].users[*].descriptor
description = "created by terraform"
}