Skip to content

Instantly share code, notes, and snippets.

@brude-softserve
Created April 30, 2021 16:21
Show Gist options
  • Save brude-softserve/482da1043d60fddaa19162efdfc54fc3 to your computer and use it in GitHub Desktop.
Save brude-softserve/482da1043d60fddaa19162efdfc54fc3 to your computer and use it in GitHub Desktop.
locals {
networks = flatten([
for network_profile in var.network_profiles : [
for network in network_profile.networks : {
cloud_account = network_profile.cloud_account
name = network.network
}
]
])
}
data "vra_fabric_network" "all_networks" {
for_each = {
for network in local.networks : "${network.cloud_account}.${network.name}" => network
}
filter = "name eq '${each.value.name}'"
}
resource "vra_network_profile" "this" {
for_each = var.network_profiles
name = each.key
description = "Network Profile"
region_id = var.region_id
fabric_network_ids = [
for key, network in data.vra_fabric_network.all_networks :
network.id
if key == "${each.value.cloud_account}.${network.name}"
]
isolation_type = each.value.isolation_type
}
network_profiles = {
"account1" : {
cloud_account = "account1"
isolation_type = "NONE"
networks = [
{
network = "network-1"
},
{
network = "network-2"
}
]
}
}
variable "network_profiles" {
type = map(object({
cloud_account = string
isolation_type = string
networks = list(object({
network = string
}))
}))
description = "List of Network Profiles"
default = {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment