fix: conditions trying to see if variables exist

This commit is contained in:
Bertrand Lanson 2024-04-13 00:28:47 +02:00
parent 7d30a246fb
commit 6a2bfa2bc9

28
main.tf
View File

@ -23,13 +23,13 @@ resource "openstack_networking_secgroup_rule_v2" "ingress" {
security_group_id = openstack_networking_secgroup_v2.this.id
tenant_id = var.tenant_id
description = try(each.value.description, false) ? each.value.description : null
ethertype = try(each.value.ethertype, false) ? each.value.ethertype : "IPv4"
protocol = try(each.value.protocol, false) ? each.value.protocol : "tcp"
port_range_min = try(each.value.port_range_min, false) ? each.value.port_range_min : null
port_range_max = try(each.value.port_range_max, false) ? each.value.port_range_max : null
remote_ip_prefix = try(each.value.remote_ip_prefix, false) ? each.value.remote_ip_prefix : null
remote_group_id = try(each.value.remote_group_id, false) ? each.value.remote_group_id : null
description = try(each.value.description, false) != false ? each.value.description : null
ethertype = try(each.value.ethertype, false) != false ? each.value.ethertype : "IPv4"
protocol = try(each.value.protocol, false) != false ? each.value.protocol : "tcp"
port_range_min = try(each.value.port_range_min, false) != false ? each.value.port_range_min : null
port_range_max = try(each.value.port_range_max, false) != false ? each.value.port_range_max : null
remote_ip_prefix = try(each.value.remote_ip_prefix, false) != false ? each.value.remote_ip_prefix : null
remote_group_id = try(each.value.remote_group_id, false) != false ? each.value.remote_group_id : null
}
resource "openstack_networking_secgroup_rule_v2" "egress" {
@ -39,11 +39,11 @@ resource "openstack_networking_secgroup_rule_v2" "egress" {
security_group_id = openstack_networking_secgroup_v2.this.id
tenant_id = var.tenant_id
description = try(each.value.description, false) ? each.value.description : null
ethertype = try(each.value.ethertype, false) ? each.value.ethertype : "IPv4"
protocol = try(each.value.protocol, false) ? each.value.protocol : "tcp"
port_range_min = try(each.value.port_range_min, false) ? each.value.port_range_min : null
port_range_max = try(each.value.port_range_max, false) ? each.value.port_range_max : null
remote_ip_prefix = try(each.value.remote_ip_prefix, false) ? each.value.remote_ip_prefix : null
remote_group_id = try(each.value.remote_group_id, false) ? each.value.remote_group_id : null
description = try(each.value.description, false) != false ? each.value.description : null
ethertype = try(each.value.ethertype, false) != false ? each.value.ethertype : "IPv4"
protocol = try(each.value.protocol, false) != false ? each.value.protocol : "tcp"
port_range_min = try(each.value.port_range_min, false) != false ? each.value.port_range_min : null
port_range_max = try(each.value.port_range_max, false) != false ? each.value.port_range_max : null
remote_ip_prefix = try(each.value.remote_ip_prefix, false) != false ? each.value.remote_ip_prefix : null
remote_group_id = try(each.value.remote_group_id, false) != false ? each.value.remote_group_id : null
}