Skip to content

Instantly share code, notes, and snippets.

@sreimers
Created March 4, 2018 12:13
Show Gist options
  • Save sreimers/c16ddc69f71a2fc841fa0246317f5e4f to your computer and use it in GitHub Desktop.
Save sreimers/c16ddc69f71a2fc841fa0246317f5e4f to your computer and use it in GitHub Desktop.
Hetzner Cloud Terraform multiple servers and datacenters
variable "hcloud_token" {}
variable "zones" {
default = {
zone0 = "nbg1-dc3"
zone1 = "fsn1-dc8"
}
}
# Configure the Hetzner Cloud Provider
provider "hcloud" {
token = "${var.hcloud_token}"
}
# Create a web server
resource "hcloud_server" "web" {
count = 4
name = "web${count.index}"
datacenter = "${lookup(var.zones, "zone${count.index % 2}")}"
image = "centos-7"
server_type = "cx11"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment