custom static ip nic
This commit is contained in:
parent
0f94aee91d
commit
c335e50eff
3 changed files with 80 additions and 25 deletions
|
|
@ -2,21 +2,29 @@ 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
|
||||
|
||||
routed = true
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,45 +6,93 @@ 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 = []
|
||||
}
|
||||
|
||||
variable "nic_ipv4" {
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "nic_labels" {
|
||||
type = map(string)
|
||||
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 = []
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue