Terraform module for managing networks, routes and subnets in the Hetzner Cloud.
It implements the following provider resources:
module "network" {
source = "github.com/peterpramb/terraform-hcloud-networks?ref=<release>"
networks = [
{
name = "network-1"
ip_range = "10.0.0.0/16"
protection = true
routes = [
{
destination = "192.168.100.0/24"
gateway = "10.0.0.100"
}
]
subnets = [
{
ip_range = "10.0.0.0/24"
network_zone = "eu-central"
type = "cloud"
}
]
labels = {
"managed" = "true"
"managed_by" = "Terraform"
}
}
]
}
See examples for more usage details.
Name | Version |
---|---|
terraform | ≥ 0.13 |
Name | Version |
---|---|
hcloud | ≥ 1.31 |
Name | Description | Type | Default | Required |
---|---|---|---|---|
networks | List of network objects to be managed. | list(map(network)) | See below | yes |
Name | Description | Type | Required |
---|---|---|---|
name | Unique name of the network. | string | yes |
ip_range | RFC1918 range of the network. | string | yes |
protection | Protect network from deletion. | bool | no |
routes | List of route objects. | list(map(route)) | no |
subnets | List of subnet objects. | list(map(subnet)) | yes |
labels | Map of user-defined labels. | map(string) | no |
Name | Description | Type | Required |
---|---|---|---|
destination | Destination host or network of this route. | string | yes |
gateway | Gateway for the route. | string | yes |
Name | Description | Type | Required |
---|---|---|---|
ip_range | Range to allocate IPs from. | string | yes |
network_zone | Name of the network zone. | string | yes |
type | Type of the subnet. | string | yes |
networks = [
{
name = "network-1"
ip_range = "10.0.0.0/16"
protection = false
routes = []
subnets = [
{
ip_range = "10.0.0.0/24"
network_zone = "eu-central"
type = "cloud"
}
]
labels = {}
}
]
Name | Description |
---|---|
networks | List of all network objects. |
network_ids | Map of all network objects indexed by ID. |
network_names | Map of all network objects indexed by name. |
network_routes | List of all network route objects. |
network_route_ids | Map of all network route objects indexed by ID. |
network_route_names | Map of all network route objects indexed by name. |
network_subnets | List of all network subnet objects. |
network_subnet_ids | Map of all network subnet objects indexed by ID. |
network_subnet_names | Map of all network subnet objects indexed by name. |
networks = [
{
"delete_protection" = false
"id" = "157411"
"ip_range" = "10.0.0.0/16"
"labels" = {}
"name" = "network-1"
"routes" = []
"subnets" = [
{
"gateway" = "10.0.0.1"
"id" = "157411-10.0.0.0/24"
"ip_range" = "10.0.0.0/24"
"network_id" = 157411
"network_zone" = "eu-central"
"type" = "cloud"
},
]
},
]
network_ids = {
"157411" = {
"delete_protection" = false
"id" = "157411"
"ip_range" = "10.0.0.0/16"
"labels" = {}
"name" = "network-1"
"routes" = []
"subnets" = [
{
"gateway" = "10.0.0.1"
"id" = "157411-10.0.0.0/24"
"ip_range" = "10.0.0.0/24"
"network_id" = 157411
"network_zone" = "eu-central"
"type" = "cloud"
},
]
}
}
network_names = {
"network-1" = {
"delete_protection" = false
"id" = "157411"
"ip_range" = "10.0.0.0/16"
"labels" = {}
"name" = "network-1"
"routes" = []
"subnets" = [
{
"gateway" = "10.0.0.1"
"id" = "157411-10.0.0.0/24"
"ip_range" = "10.0.0.0/24"
"network_id" = 157411
"network_zone" = "eu-central"
"type" = "cloud"
},
]
}
}
network_routes = []
network_route_ids = {}
network_route_names = {}
network_subnets = [
{
"gateway" = "10.0.0.1"
"id" = "157411-10.0.0.0/24"
"ip_range" = "10.0.0.0/24"
"name" = "network-1:10.0.0.0/24"
"network_id" = 157411
"network_name" = "network-1"
"network_zone" = "eu-central"
"type" = "cloud"
},
]
network_subnet_ids = {
"157411-10.0.0.0/24" = {
"gateway" = "10.0.0.1"
"id" = "157411-10.0.0.0/24"
"ip_range" = "10.0.0.0/24"
"name" = "network-1:10.0.0.0/24"
"network_id" = 157411
"network_name" = "network-1"
"network_zone" = "eu-central"
"type" = "cloud"
}
}
network_subnet_names = {
"network-1:10.0.0.0/24" = {
"gateway" = "10.0.0.1"
"id" = "157411-10.0.0.0/24"
"ip_range" = "10.0.0.0/24"
"name" = "network-1:10.0.0.0/24"
"network_id" = 157411
"network_name" = "network-1"
"network_zone" = "eu-central"
"type" = "cloud"
}
}
This module is released under the MIT License.