gitlab mail
jj jj

Hetzner provision module

A really simple module grouping several commonly used together resources. Might grow as time goes on, might not.

Required variables

  • hcloud_token : API token allowing access to Hetzner API

Optional variables

  • hcloud_ssh_keys: Map(string) , Key is the name of ssh key to used in hetzner cloud, Value is an ssh pubkey to upload

  • hcloud_networks: Map(string) , Key is the name of a network to be used in hetzner cloud, Value is an ip range as string in IP/MASK format

  • hcloud_network_subnets: Map(Obj) , Key is the name of a subnet to be used in hetzner cloud, Value is an object with following parameters:

    • network_name: String , Name of network this subnet belongs to
    • type: String , type of subnet, allowed values are “server”, “cloud” or “vswitch”
    • network_zone: String , zone of the network, see hetzner docs for ref
    • ip_range: String , ip range in IP/MASK format, must be a subnet of “network” ip_range
  • hcloud_servers: Map(Obj) , Key is the name of a server node to be used in hetzner cloud, Value is an object with following parameters:

    • image: String , Name of the image to use ,check hetzner docs for details
    • server_type: String , Server type to use ,check hetzner docs for details
    • location: String , Location to use ,check hetzner docs for details
    • ssh_keys: List(String) , Names of ssh-keys to grant root access to
    • user_data: String , cloud-init user-data definition, see cloud-init docs for details
    • labels: Map(string) , Key is the name of the tag to set, Value is the value of the tag
  • privnet_servers: Map(Obj) , Key is the name of a server node to be used in hetzner cloud, Value is an object with following parameters:

    • ip: String , IP to assign the the server from the subnet
    • subnet_name: String , Name of subnet

Example tfvars file

hcloud_token = "TOKEN"
hcloud_ssh_keys = {
  "universal" = "ssh-rsa AAAA"
}
hcloud_networks = {
  "mynet" = "10.0.0.0/8"
}
hcloud_network_subnets = {
  "mysubnet" = {
    network_name = "mynet"
    type         = "cloud"
    network_zone = "eu-central"
    ip_range     = "10.0.0.0/24"
  }
}

hcloud_servers = {
  "tester.jjlabs.dev" = {
    image       = "rocky-9"
    server_type = "cx11"
    location    = "fsn1"
    ssh_keys    = ["universal"]
    user_data   = null
    labels = {
      test  = "tag"
      test2 = "TAG"
    }
  }
}
privnet_servers = {
  "tester.jjlabs.dev" = {
    subnet_name = "mysubnet"
    ip          = "10.0.0.223"
  }
}
source url ssh clone url http clone url