/terraform-hcloud-network

Terraform module to provision Network resouces in Hetzner Cloud

Primary LanguageHCLMIT LicenseMIT

Description

Terraform module to help with provisioning Network, Subnet and Network Route resources in Hetzner Cloud.

Usage

# Configure the Hetzner Cloud Provider
provider "hcloud" {
  token = var.hcloud_token
}

locals {
  network_routes = tomap({
    "0.0.0.0/0" = "10.100.0.2"
  })
}

module "net" {
  source = "../../"

  create_network = true

  network_name                     = "example-network"
  network_ip_cidr_range            = "10.100.0.0/16"
  network_delete_protection        = false
  network_expose_routes_to_vswitch = false
  network_labels = {
    name        = "example-network"
    environment = "dev"
  }

  create_subnet         = true
  subnet_type           = "cloud"
  subnet_network_zone   = "eu-central"
  subnet_ip_cidr_ranges = ["10.100.20.0/24", "10.100.30.0/24"]

  create_network_route = true
  network_routes       = local.network_routes
}

Requirements

Name Version
terraform >= 1.2.0
hcloud >= 1.47

Providers

Name Version
hcloud >= 1.47

Modules

No modules.

Resources

Name Type
hcloud_network.network resource
hcloud_network_route.private_net resource
hcloud_network_subnet.subnet resource

Inputs

Name Description Type Default Required
create_network A boolean to check whether to create a network resource or not. bool false no
create_network_route A boolean to check whether to create a Network Route resource or not. bool false no
create_subnet A boolean to check whether to create a subent resource or not. bool false no
network_delete_protection Enable or disable delete protection. bool false no
network_expose_routes_to_vswitch Enable or disable exposing the routes to the vSwitch connection. The exposing only takes effect if a vSwitch connection is active.. bool false no
network_ip_cidr_range IP CIDR Range of the whole Network which must span all included subnets and route destinations. Must be one of the private ipv4 ranges of RFC1918. string "10.0.0.0/8" no
network_labels User-defined labels (key-value pairs) should be created with. map(any) {} no
network_name Name of the network to be created (must be unique per project). string "" no
network_routes A map between route_destinations to route_gateways. map(any) {} no
subnet_ip_cidr_ranges Range to allocate IPs from. Must be a subnet of the ip_range of the Network and must not overlap with any other subnets or with any destinations in routes. list(string)
[
"10.0.0.0/24"
]
no
subnet_network_zone Name of the network zone e.g. eu-central, us-east, us-west. string "" no
subnet_type Type of subnet e.g. server, cloud or vswitch. string "" no
subnet_vswitch_id ID of the vswitch, Required if type is vswitch number null no

Outputs

Name Description
network_delete_protection Enable or disable delete protection.
network_expose_routes_to_vswitch Enable or disable exposing the routes to the vSwitch connection. The exposing only takes effect if a vSwitch connection is active..
network_id Unique ID of the network.
network_ip_cidr_range IP CIDR Range of the whole Network which must span all included subnets and route destinations. Must be one of the private ipv4 ranges of RFC1918.
network_labels User-defined labels (key-value pairs) should be created with.
network_name Name of the network to be created (must be unique per project).
network_route_destination Destination network or host of this route. Must be a subnet of the ip_range of the Network. Must not overlap with an existing ip_range in any subnets or with any destinations in other routes or with the first ip of the networks ip_range or with 172.31.1.1.
network_route_gateway Gateway for the route. Cannot be the first ip of the networks ip_range and also cannot be 172.31.1.1 as this IP is being used as a gateway for the public network interface of servers.
network_route_id ID of the Network the route should be added to.
network_route_network_id ID of the Network the route should be added to.
subnet_id ID of the Network subnet.
subnet_ip_cidr_range Range to allocate IPs from. Must be a subnet of the ip_range of the Network and must not overlap with any other subnets or with any destinations in routes.
subnet_network_id ID of the Network the subnet should be added to.
subnet_network_zone Name of the network zone e.g. eu-central, us-east, us-west.
subnet_type Type of subnet e.g. server, cloud or vswitch.
subnet_vswitch_id ID of the vswitch, Required if type is vswitch