diff --git a/network/main.tf b/network/main.tf index f9ca504..1eae91a 100644 --- a/network/main.tf +++ b/network/main.tf @@ -2,21 +2,29 @@ resource "stackit_network" "this" { project_id = var.project_id name = var.name - ipv4_nameservers = var.ipv4_nameservers - labels = var.labels - - routed = true + 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.static_ipv4 == null ? 0 : 1 + count = var.nic_ipv4 == null ? 0 : 1 - project_id = var.project_id network_id = stackit_network.this.network_id + project_id = var.project_id - ipv4 = var.static_ipv4 + ipv4 = var.nic_ipv4 labels = var.nic_labels - name = var.nic_name == null ? "${var.name}-nic" : var.nic_name + 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 diff --git a/network/output.tf b/network/output.tf index 14a3f9c..ddf472c 100644 --- a/network/output.tf +++ b/network/output.tf @@ -13,7 +13,6 @@ output "network_interface_id" { value = try(stackit_network_interface.static[0].network_interface_id, null) } -output "static_ipv4" { - description = "IPv4 address assigned to NIC (null when not used)" - value = var.static_ipv4 +output "nic_ipv4_list" { + value = try(stackit_network_interface.static[*].ipv4, null) } diff --git a/network/variables.tf b/network/variables.tf index 5bbe8e6..d41ef18 100644 --- a/network/variables.tf +++ b/network/variables.tf @@ -6,31 +6,74 @@ variable "name" { type = string } +variable "ipv4_gateway" { + type = string + default = null +} + variable "ipv4_nameservers" { type = list(string) default = [] } +variable "ipv4_prefix" { + type = string # CIDR, only for NON-routed nets + default = null +} + +variable "ipv4_prefix_length" { + type = number # e.g. 24 + default = null +} + +variable "ipv6_gateway" { + type = string + default = null +} + +variable "ipv6_nameservers" { + type = list(string) + default = [] +} + +variable "ipv6_prefix" { + type = string + default = null +} + +variable "ipv6_prefix_length" { + type = number + default = null +} + variable "labels" { type = map(string) default = {} } -variable "static_ipv4" { - type = string - description = "If set, a NIC will be created with this IPv4." - default = null +variable "no_ipv4_gateway" { + type = bool + default = false } -variable "nic_name" { - type = string - default = null +variable "no_ipv6_gateway" { + type = bool + default = false +} + +variable "routed" { + type = bool + default = true } variable "nic_allowed_addresses" { - type = list(string) - description = "Additional CIDR blocks for NIC" - default = [] + type = list(string) + default = [] +} + +variable "nic_ipv4" { + type = string + default = null } variable "nic_labels" { @@ -38,13 +81,18 @@ variable "nic_labels" { default = {} } +variable "nic_name" { + type = string + default = null +} + variable "nic_security" { type = bool - default = true + default = false + nullable = false } variable "nic_security_group_ids" { - type = list(string) - description = "nic_security must be set to true" - default = [] + type = list(string) + default = [] }