aboutsummaryrefslogtreecommitdiffstats
path: root/main.tf
blob: 058b5be4bbba3abc8ae95c339e5964053c1ddfeb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
terraform {
  required_providers {
    hcloud = {
      source  = "hetznercloud/hcloud"
      version = "~> 1.68.0"
    }
  }
}

provider "hcloud" {
  token = var.hcloud_token
}

variable "hcloud_token" {
  type      = string
  sensitive = true
}

data "hcloud_image" "openbsd" {
  with_selector = "os=openbsd,version=7.9,arch=amd64"
  most_recent   = true
}

resource "hcloud_ssh_key" "default" {
  name       = "default-key"
  public_key = file("~/.ssh/id_rsa.pub")
}

resource "hcloud_server" "web01" {
  name        = "web01"
  image       = data.hcloud_image.openbsd.id
  server_type = "cx23"
  location    = "nbg1"
  ssh_keys    = [hcloud_ssh_key.default.id]

  public_net {
    ipv4_enabled = true
    ipv6_enabled = true
  }
}