terraform-modules/network/main.tf

31 lines
1.1 KiB
HCL

resource "stackit_network" "this" {
project_id = var.project_id
name = var.name
ipv4_gateway = var.routed == false ? var.ipv4_gateway : null
ipv4_nameservers = var.ipv4_nameservers
ipv4_prefix = var.ipv4_prefix
ipv4_prefix_length = var.ipv4_prefix_length
ipv6_gateway = var.routed == false ? var.ipv6_gateway : null
ipv6_nameservers = var.ipv6_nameservers
ipv6_prefix = var.ipv6_prefix
ipv6_prefix_length = var.ipv6_prefix_length
labels = var.labels
no_ipv4_gateway = var.no_ipv4_gateway
no_ipv6_gateway = var.no_ipv6_gateway
routed = var.routed
}
resource "stackit_network_interface" "static" {
count = var.nic_ipv4 == null ? 0 : 1
network_id = stackit_network.this.network_id
project_id = var.project_id
ipv4 = var.nic_ipv4
labels = var.nic_labels
name = var.nic_name != null ? var.nic_name : "${var.name}-nic"
security = var.nic_security
security_group_ids = var.nic_security ? var.nic_security_group_ids : null
allowed_addresses = var.nic_security ? var.nic_allowed_addresses : null
}