From 8c8f01dace21adf78050452edc4cf08d01fa1daa Mon Sep 17 00:00:00 2001 From: danischm Date: Mon, 11 Nov 2024 22:34:25 +0100 Subject: [PATCH] Comment out unused parts and fix device defaults --- README.md | 7 ---- fmc_devices.tf | 12 +++--- fmc_existing.tf | 98 ++++++++++++++++++++++++------------------------- 3 files changed, 55 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 23803be..ad064d3 100644 --- a/README.md +++ b/README.md @@ -334,24 +334,17 @@ module "fmc" { | [fmc_device_cluster.cluster](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/device_cluster) | data source | | [fmc_device_physical_interfaces.physical_interface](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/device_physical_interfaces) | data source | | [fmc_device_subinterfaces.sub_interfaces](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/device_subinterfaces) | data source | -| [fmc_device_vni.vni](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/device_vni) | data source | | [fmc_devices.device](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/devices) | data source | | [fmc_dynamic_objects.dynamicobject](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/dynamic_objects) | data source | -| [fmc_extended_acl.extended_acl](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/extended_acl) | data source | -| [fmc_file_policies.file_policy](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/file_policies) | data source | | [fmc_ftd_nat_policies.ftdnatpolicy](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/ftd_nat_policies) | data source | | [fmc_host_objects.host](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/host_objects) | data source | | [fmc_ips_policies.ips_policy](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/ips_policies) | data source | -| [fmc_network_analysis_policy.network_analysis_policy](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/network_analysis_policy) | data source | | [fmc_network_group_objects.networkgroup](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/network_group_objects) | data source | | [fmc_network_objects.network](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/network_objects) | data source | | [fmc_port_group_objects.portgroup](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/port_group_objects) | data source | | [fmc_port_objects.port](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/port_objects) | data source | | [fmc_security_zones.securityzone](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/security_zones) | data source | | [fmc_sgt_objects.sgt](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/sgt_objects) | data source | -| [fmc_smart_license.smart_license](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/smart_license) | data source | -| [fmc_standard_acl.standard_acl](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/standard_acl) | data source | -| [fmc_syslog_alerts.syslog_alert](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/syslog_alerts) | data source | | [fmc_url_objects.url](https://registry.terraform.io/providers/CiscoDevNet/fmc/latest/docs/data-sources/url_objects) | data source | | [utils_yaml_merge.defaults](https://registry.terraform.io/providers/netascode/utils/latest/docs/data-sources/yaml_merge) | data source | | [utils_yaml_merge.model](https://registry.terraform.io/providers/netascode/utils/latest/docs/data-sources/yaml_merge) | data source | diff --git a/fmc_devices.tf b/fmc_devices.tf index 83fefbe..29535f3 100644 --- a/fmc_devices.tf +++ b/fmc_devices.tf @@ -116,9 +116,9 @@ resource "fmc_device_physical_interfaces" "physical_interface" { # Optional if_name = try(each.value.data.name, null) security_zone_id = try(local.map_securityzones[each.value.data.security_zone].id, null) - enabled = try(each.value.data.enabled, local.defaults.fmc.domains.devices.physical_interfaces.enabled) + enabled = try(each.value.data.enabled, local.defaults.fmc.domains.devices.devices.physical_interfaces.enabled) mtu = try(each.value.data.mtu, null) - mode = try(each.value.data.mode, local.defaults.fmc.domains.devices.physical_interfaces.mode) + mode = try(each.value.data.mode, local.defaults.fmc.domains.devices.devices.physical_interfaces.mode) ipv4_static_address = try(each.value.data.ipv4_static_address, null) ipv4_static_netmask = try(each.value.data.ipv4_static_netmask, null) ipv4_dhcp_enabled = try(each.value.data.ipv4_dhcp, null) @@ -126,7 +126,7 @@ resource "fmc_device_physical_interfaces" "physical_interface" { ipv6_address = try(each.value.data.ipv6_address, null) ipv6_prefix = try(each.value.data.ipv6_prefix, null) ipv6_enforce_eui = try(each.value.data.ipv6_enforce_eui64, null) - description = try(each.value.data.description, local.defaults.fmc.domains.devices.physical_interfaces.description, null) + description = try(each.value.data.description, local.defaults.fmc.domains.devices.devices.physical_interfaces.description, null) depends_on = [ data.fmc_device_physical_interfaces.physical_interface, @@ -181,7 +181,7 @@ resource "fmc_device_subinterfaces" "sub_interfaces" { ipv6_enforce_eui = try(each.value.data.ipv6_enforce_eui, null) ipv6_prefix = try(each.value.data.ipv6_prefix, null) management_only = try(each.value.data.management_only, null) - mode = try(each.value.data.mode, local.defaults.fmc.domains.devices.physical_interfaces.subinterfaces.mode, null) + mode = try(each.value.data.mode, local.defaults.fmc.domains.devices.devices.physical_interfaces.subinterfaces.mode, null) mtu = try(each.value.data.mtu, null) priority = try(each.value.data.priority, null) security_zone_id = try(local.map_securityzones[each.value.data.security_zone].id, null) @@ -251,7 +251,7 @@ resource "fmc_device_vni" "vni" { security_zone_id = try(local.map_securityzones[each.value.data.security_zone].id, null) if_name = each.value.data.name enabled = try(each.value.data.enabled, null) - description = try(each.value.data.description, local.defaults.fmc.domains.devices.vnis.description, "VNI Interface") + description = try(each.value.data.description, local.defaults.fmc.domains.devices.devices.vnis.description, "VNI Interface") priority = try(each.value.data.priority, null) vnid = each.value.data.vni_id segment_id = try(each.value.data.vni_segment_id, null) @@ -322,7 +322,7 @@ resource "fmc_staticIPv4_route" "ipv4staticroute" { } # Optional - is_tunneled = try(each.value.tunneled, local.defaults.fmc.domains.devices.ipv4_static_routes.tunneled, null) + is_tunneled = try(each.value.tunneled, local.defaults.fmc.domains.devices.devices.ipv4_static_routes.tunneled, null) depends_on = [ fmc_device_physical_interfaces.physical_interface, diff --git a/fmc_existing.tf b/fmc_existing.tf index 3257392..e2f7560 100644 --- a/fmc_existing.tf +++ b/fmc_existing.tf @@ -3,17 +3,17 @@ ### locals { - data_smart_license = contains(keys(try(local.data_existing.fmc.system, {})), "smart_license") ? [local.data_existing.fmc.system.smart_license] : [] - data_syslog_alerts = [for obj in try(local.data_existing.fmc.system.syslog_alerts, []) : obj.name] - data_devices = [for obj in try(local.data_existing.fmc.domains[0].devices.devices, []) : obj.name] - data_clusters = [for obj in try(local.data_existing.fmc.domains[0].devices.clusters, []) : obj.name] - data_accesspolicies = [for obj in try(local.data_existing.fmc.domains[0].policies.access_policies, []) : obj.name] - data_ftdnatpolicies = [for obj in try(local.data_existing.fmc.domains[0].policies.ftd_nat_policies, []) : obj.name] - data_ipspolicies = [for obj in try(local.data_existing.fmc.domains[0].policies.ips_policies, []) : obj.name] - data_filepolicies = [for obj in try(local.data_existing.fmc.domains[0].policies.file_policies, []) : obj.name] - data_network_analysis_policies = [for obj in try(local.data_existing.fmc.domains[0].network_analysis_policies, []) : obj.name] - data_hosts = [for obj in try(local.data_existing.fmc.domains[0].objects.hosts, []) : obj.name] - data_networks = [for obj in try(local.data_existing.fmc.domains[0].objects.networks, []) : obj.name] + # data_smart_license = contains(keys(try(local.data_existing.fmc.system, {})), "smart_license") ? [local.data_existing.fmc.system.smart_license] : [] + # data_syslog_alerts = [for obj in try(local.data_existing.fmc.system.syslog_alerts, []) : obj.name] + data_devices = [for obj in try(local.data_existing.fmc.domains[0].devices.devices, []) : obj.name] + data_clusters = [for obj in try(local.data_existing.fmc.domains[0].devices.clusters, []) : obj.name] + data_accesspolicies = [for obj in try(local.data_existing.fmc.domains[0].policies.access_policies, []) : obj.name] + data_ftdnatpolicies = [for obj in try(local.data_existing.fmc.domains[0].policies.ftd_nat_policies, []) : obj.name] + data_ipspolicies = [for obj in try(local.data_existing.fmc.domains[0].policies.ips_policies, []) : obj.name] + # data_filepolicies = [for obj in try(local.data_existing.fmc.domains[0].policies.file_policies, []) : obj.name] + # data_network_analysis_policies = [for obj in try(local.data_existing.fmc.domains[0].network_analysis_policies, []) : obj.name] + data_hosts = [for obj in try(local.data_existing.fmc.domains[0].objects.hosts, []) : obj.name] + data_networks = [for obj in try(local.data_existing.fmc.domains[0].objects.networks, []) : obj.name] #data_ranges = [] data_networkgroups = [for obj in try(local.data_existing.fmc.domains[0].objects.network_groups, []) : obj.name] data_ports = [for obj in try(local.data_existing.fmc.domains[0].objects.ports, []) : obj.name] @@ -48,15 +48,15 @@ locals { ] ]) - data_vni_interfaces = flatten([ - for device in try(local.data_existing.fmc.domains[0].devices.devices, []) : [ - for vni in try(device.vnis, []) : { - key = "${device.name}/${vni.name}/${vni.vni_id}" - device_id = local.map_devices[device.name].id - vni_name = vni - } - ] - ]) + # data_vni_interfaces = flatten([ + # for device in try(local.data_existing.fmc.domains[0].devices.devices, []) : [ + # for vni in try(device.vnis, []) : { + # key = "${device.name}/${vni.name}/${vni.vni_id}" + # device_id = local.map_devices[device.name].id + # vni_name = vni + # } + # ] + # ]) data_vni_interfaces_list = flatten([ for device in try(local.data_existing.fmc.domains[0].devices.devices, []) : [ @@ -69,11 +69,11 @@ locals { # Data sources ### -data "fmc_smart_license" "smart_license" { - for_each = toset(local.data_smart_license) +# data "fmc_smart_license" "smart_license" { +# for_each = toset(local.data_smart_license) - virtual_account = try(each.key, null) -} +# virtual_account = try(each.key, null) +# } data "fmc_access_policies" "accesspolicy" { for_each = toset(local.data_accesspolicies) @@ -131,17 +131,17 @@ data "fmc_port_group_objects" "portgroup" { # name = each.key #} -data "fmc_standard_acl" "standard_acl" { - for_each = toset(local.data_standard_access_lists) +# data "fmc_standard_acl" "standard_acl" { +# for_each = toset(local.data_standard_access_lists) - name = each.key -} +# name = each.key +# } -data "fmc_extended_acl" "extended_acl" { - for_each = toset(local.data_extended_access_lists) +# data "fmc_extended_acl" "extended_acl" { +# for_each = toset(local.data_extended_access_lists) - name = each.key -} +# name = each.key +# } data "fmc_security_zones" "securityzone" { for_each = toset(local.data_securityzones) @@ -161,17 +161,17 @@ data "fmc_ips_policies" "ips_policy" { name = each.key } -data "fmc_file_policies" "file_policy" { - for_each = toset(local.data_filepolicies) +# data "fmc_file_policies" "file_policy" { +# for_each = toset(local.data_filepolicies) - name = each.key -} +# name = each.key +# } -data "fmc_network_analysis_policy" "network_analysis_policy" { - for_each = toset(local.data_network_analysis_policies) +# data "fmc_network_analysis_policy" "network_analysis_policy" { +# for_each = toset(local.data_network_analysis_policies) - name = each.key -} +# name = each.key +# } data "fmc_devices" "device" { for_each = toset(local.data_devices) @@ -209,12 +209,12 @@ data "fmc_device_subinterfaces" "sub_interfaces" { ] } -data "fmc_device_vni" "vni" { - for_each = { for object in local.data_vni_interfaces : object.key => object } +# data "fmc_device_vni" "vni" { +# for_each = { for object in local.data_vni_interfaces : object.key => object } - name = each.value.vni_name - device_id = each.value.device_id -} +# name = each.value.vni_name +# device_id = each.value.device_id +# } data "fmc_sgt_objects" "sgt" { for_each = toset(local.data_sgts) @@ -228,8 +228,8 @@ data "fmc_url_objects" "url" { name = each.key } -data "fmc_syslog_alerts" "syslog_alert" { - for_each = toset(local.data_syslog_alerts) +# data "fmc_syslog_alerts" "syslog_alert" { +# for_each = toset(local.data_syslog_alerts) - name = each.key -} +# name = each.key +# }