-
-
Save brude-softserve/482da1043d60fddaa19162efdfc54fc3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
] | |
]) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
network_profiles = { | |
"account1" : { | |
cloud_account = "account1" | |
isolation_type = "NONE" | |
networks = [ | |
{ | |
network = "network-1" | |
}, | |
{ | |
network = "network-2" | |
} | |
] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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