Hi All,
I have the following code in a module which is called as part of a longer process:
variable cloud_account {}
variable zoneInfo {}
# Create each specified project
resource "vra_project" "this" {
for_each = { for proj in var.cloud_account.projects : proj.name => proj }
name = each.value.name
description = each.value.description
machine_naming_template = each.value.machine_naming_template
zone_assignments {
zone_id = var.zoneInfo.id
priority = 1
max_instances = 0
}
}
The input for this is as follows (cut from a larger input file)
projects = [
{
name = "Development",
description = "Development project"
administrator_users = {email="Administrator@automationpro.lan"},
machine_naming_template = "dev-$${resource.name}-$${####}",
},
{
name = "Staging",
description = "Staging project"
machine_naming_template = "stg-$${resource.name}-$${####}",
},
{
name = "Production",
description = "Production project"
machine_naming_template = "prd-$${resource.name}-$${####}",
},
{
name = "DR",
description = "DR project"
machine_naming_template = "dr-$${resource.name}-$${####}",
}
],
What I am trying to achieve is to loop through each project and create which is working fine. However, I am not sure how to deal with the administrator_users? There could be 1,2,10, any number of them defined for each project, so in my mind, I am thinking a loop within a loop which I believe is not possible.
The roles are added as per the following, and repeated for each (full example here)
administrator_roles {
email = "jason@vra.local"
type = "user"
}
Any advice on how I should go about this?
For reference this is working with the vRA Provider (if that matters) found here
Thanks for any and all help in advance.