Files
mgmt/examples/lang/hetzner_vm0.mcl
Jef Masereel b26f842de1 engine: resources: Add hetzner:vm resource
Hetzner cloud resource using hcloud-go. Requires polling via Meta:poll param. This first commit provides a stable vm resource with support for the basic functions of creating, deleting and updating a live server instance. SSH key handling does still require some attention to make sure checkapply can detect and update live changes to the specified keylist. A dedicated hetzner:sshkeys resource might be in order to make sure the keyset is handled correctly if there are multiple hetzner:vm resources running under the same Hetzner project. All remarks for future improvements are indicated with a TODO prefix
2022-04-20 14:24:25 -04:00

52 lines
1.5 KiB
Plaintext

import "os"
#import "deploy"
# read token from a local path outside repo:
$f = "../localsecrets/apitoken.txt"
$token = os.readfile($f)
# alternatively, read from the deploy:
# $token = deploy.readfile(...)
# or give the string directly:
# $token = "..."
hetzner:vm "resourcedemo" {
# generate a token on https://console.hetzner.cloud
# NOTE: SSH keys must also be registered via console
apitoken => $token,
# set server state (``, `absent`,`exists`, `running`, `off`)
# default: undefined state. Don't specify this param, or set ""
state => "absent",
# choose server protection policy (``, `ignore`, `ifneeded`)
# default: `` throws error to prevent destructive rebuilds
allowrebuild => "",
# serverconfig params: full options must be requested from Hetzner API
# static reference on https://github.com/JefMasereel/hcloud-go-getopts
# for example:
servertype => "cx11", # `cx11`, `cx21`, `cx31`
datacenter => "hel1-dc2", # `nbg1-dc3`, `fsn1-dc14`, `hel1-dc2`
image => "debian-10", # `centos-7`, `ubuntu-18.04`, `debian-10`
# provide a cloud-init script that will be run at server creation (optional)
userdata => "",
# set rescue mode (`linux32`/`linux64`/`freebsd64`/``)
# default: `` disables rescue mode
serverrescuemode => "linux64",
# list the SSH keys to be enabled when using rescue mode
# note: must be a subset of the keys registered with the project!
serverrescuekeys => ["bootstrap-test-key",],
# set wait interval and timeout in seconds
waitinterval => 1,
waittimeout => 5*60,
# set polling interval in seconds
Meta:poll => 10,
}