-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathcc_network_profiles.tf
More file actions
49 lines (42 loc) · 2.64 KB
/
cc_network_profiles.tf
File metadata and controls
49 lines (42 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
locals {
switching_profile_templates = {
for profile in try(local.catalyst_center.network_profiles.switching, {}) : profile.name => {
"templates" : [{
"type" : "cli.templates"
"attributes" : [for template in try(profile.dayn_templates, []) :
{
"template_id" : try(catalystcenter_template.regular_template[template].id, catalystcenter_template.composite_template[template].id, catalystcenter_template.regular_template[local.template_name_to_key[template]].id, catalystcenter_template.composite_template[local.template_name_to_key[template]].id, null)
}
]
},
{
"type" : "day0.templates"
"attributes" : [for template in try(profile.onboarding_templates, []) :
{
"template_id" : try(catalystcenter_template.regular_template[template].id, catalystcenter_template.composite_template[template].id, catalystcenter_template.regular_template[local.template_name_to_key[template]].id, catalystcenter_template.composite_template[local.template_name_to_key[template]].id, null)
}
]
}]
}
}
}
resource "catalystcenter_network_profile" "switching_network_profile" {
for_each = var.manage_global_settings || (!var.manage_global_settings && length(var.managed_sites) == 0) ? local.switching_profile_templates : {}
name = each.key
type = "switching"
templates = each.value.templates
}
data "catalystcenter_network_profile" "switching_network_profile" {
for_each = var.manage_global_settings == false && length(var.managed_sites) != 0 ? local.switching_profile_templates : {}
name = each.key
}
resource "catalystcenter_network_profile_for_sites_assignments" "site_to_network_profile" {
for_each = { for np in try(local.catalyst_center.network_profiles.switching, []) : np.name => np if length(try(np.sites, [])) > 0 && anytrue([for site in np.sites : contains(local.sites, site)]) }
network_profile_id = try(catalystcenter_network_profile.switching_network_profile[each.key].id, data.catalystcenter_network_profile.switching_network_profile[each.key].id)
items = [
for site in each.value.sites : {
id = var.use_bulk_api ? coalesce(local.site_id_list_bulk[site], local.data_source_created_sites_list[site]) : local.site_id_list[site]
} if contains(local.sites, site)
]
depends_on = [catalystcenter_area.area_0, catalystcenter_area.area_1, catalystcenter_area.area_2, catalystcenter_area.area_3, catalystcenter_building.building, catalystcenter_floor.floor, catalystcenter_areas.bulk_areas, catalystcenter_buildings.bulk_buildings, catalystcenter_floors.bulk_floors, data.catalystcenter_sites.created_sites]
}