2024-04-11 21:37:08 +00:00
|
|
|
terraform {
|
|
|
|
required_version = ">= 1.0.0"
|
|
|
|
required_providers {
|
|
|
|
openstack = {
|
|
|
|
source = "terraform-provider-openstack/openstack"
|
2024-08-19 20:39:10 +00:00
|
|
|
version = ">= 1.54"
|
2024-04-11 21:37:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_networking_secgroup_v2" "this" {
|
|
|
|
name = var.name
|
|
|
|
description = var.description
|
|
|
|
tenant_id = var.tenant_id
|
|
|
|
delete_default_rules = var.delete_default_rules
|
|
|
|
tags = var.tags
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_networking_secgroup_rule_v2" "ingress" {
|
|
|
|
for_each = var.ingress_rules
|
|
|
|
|
|
|
|
direction = "ingress"
|
|
|
|
security_group_id = openstack_networking_secgroup_v2.this.id
|
|
|
|
tenant_id = var.tenant_id
|
|
|
|
|
2024-04-12 22:31:44 +00:00
|
|
|
description = try(each.value.description, false) != false ? each.value.description : "Terraform managed."
|
2024-04-12 22:28:47 +00:00
|
|
|
ethertype = try(each.value.ethertype, false) != false ? each.value.ethertype : "IPv4"
|
2024-04-17 11:07:27 +00:00
|
|
|
protocol = try(each.value.protocol, false) != false ? each.value.protocol : null
|
2024-04-12 22:28:47 +00:00
|
|
|
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
|
2024-09-30 20:44:49 +00:00
|
|
|
remote_group_id = try(each.value.remote_group_id, false) != false ? (each.value.remote_group_id == "self" ? openstack_networking_secgroup_v2.this.id : each.value.remote_group_id) : null
|
2024-04-11 21:37:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_networking_secgroup_rule_v2" "egress" {
|
|
|
|
for_each = var.egress_rules
|
|
|
|
|
|
|
|
direction = "egress"
|
|
|
|
security_group_id = openstack_networking_secgroup_v2.this.id
|
|
|
|
tenant_id = var.tenant_id
|
|
|
|
|
2024-04-12 22:31:44 +00:00
|
|
|
description = try(each.value.description, false) != false ? each.value.description : "Terraform managed."
|
2024-04-12 22:28:47 +00:00
|
|
|
ethertype = try(each.value.ethertype, false) != false ? each.value.ethertype : "IPv4"
|
2024-04-17 10:56:39 +00:00
|
|
|
protocol = try(each.value.protocol, false) != false ? each.value.protocol : null
|
2024-04-12 22:28:47 +00:00
|
|
|
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
|
2024-09-30 20:44:49 +00:00
|
|
|
remote_group_id = try(each.value.remote_group_id, false) != false ? (each.value.remote_group_id == "self" ? openstack_networking_secgroup_v2.this.id : each.value.remote_group_id) : null
|
2024-04-11 21:37:08 +00:00
|
|
|
}
|