network tf module
This commit is contained in:
parent
4e9fc826bf
commit
0f94aee91d
4 changed files with 101 additions and 0 deletions
23
network/main.tf
Normal file
23
network/main.tf
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
resource "stackit_network" "this" {
|
||||||
|
project_id = var.project_id
|
||||||
|
name = var.name
|
||||||
|
|
||||||
|
ipv4_nameservers = var.ipv4_nameservers
|
||||||
|
labels = var.labels
|
||||||
|
|
||||||
|
routed = true
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "stackit_network_interface" "static" {
|
||||||
|
count = var.static_ipv4 == null ? 0 : 1
|
||||||
|
|
||||||
|
project_id = var.project_id
|
||||||
|
network_id = stackit_network.this.network_id
|
||||||
|
|
||||||
|
ipv4 = var.static_ipv4
|
||||||
|
labels = var.nic_labels
|
||||||
|
name = var.nic_name == null ? "${var.name}-nic" : var.nic_name
|
||||||
|
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
|
||||||
|
}
|
||||||
19
network/output.tf
Normal file
19
network/output.tf
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
output "network_id" {
|
||||||
|
description = "Network ID"
|
||||||
|
value = stackit_network.this.network_id
|
||||||
|
}
|
||||||
|
|
||||||
|
output "network_name" {
|
||||||
|
description = "Network name"
|
||||||
|
value = stackit_network.this.name
|
||||||
|
}
|
||||||
|
|
||||||
|
output "network_interface_id" {
|
||||||
|
description = "NIC 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
|
||||||
|
}
|
||||||
9
network/providers.tf
Normal file
9
network/providers.tf
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
terraform {
|
||||||
|
required_version = ">= 1.9.0"
|
||||||
|
required_providers {
|
||||||
|
stackit = {
|
||||||
|
source = "stackitcloud/stackit"
|
||||||
|
version = "0.56.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
50
network/variables.tf
Normal file
50
network/variables.tf
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
variable "project_id" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "name" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ipv4_nameservers" {
|
||||||
|
type = list(string)
|
||||||
|
default = []
|
||||||
|
}
|
||||||
|
|
||||||
|
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 "nic_name" {
|
||||||
|
type = string
|
||||||
|
default = null
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "nic_allowed_addresses" {
|
||||||
|
type = list(string)
|
||||||
|
description = "Additional CIDR blocks for NIC"
|
||||||
|
default = []
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "nic_labels" {
|
||||||
|
type = map(string)
|
||||||
|
default = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "nic_security" {
|
||||||
|
type = bool
|
||||||
|
default = true
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "nic_security_group_ids" {
|
||||||
|
type = list(string)
|
||||||
|
description = "nic_security must be set to true"
|
||||||
|
default = []
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue