-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroot.tf
More file actions
72 lines (66 loc) · 1.34 KB
/
root.tf
File metadata and controls
72 lines (66 loc) · 1.34 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
terraform {
required_providers {
hcloud = {
source = "hetznercloud/hcloud"
version = "~> 1.56.0"
}
}
}
variable "hcloud_token" {
sensitive = true
}
provider "hcloud" {
token = var.hcloud_token
}
resource "hcloud_ssh_key" "mckey" {
name = "minecraft_key"
public_key = file("mckey.pub")
}
resource "hcloud_volume" "mcworld" {
name = "MC-world"
size = 10
delete_protection = true
automount = true
format = "ext4"
labels = {
minecraft = 1
}
lifecycle {
prevent_destroy = true
}
}
resource "hcloud_volume_attachment" "mcvolattach" {
volume_id = hcloud_volume.mcworld.id
server_id = hcloud_server.minecraft.id
automount = true
}
resource "hcloud_server" "minecraft" {
name = "Minecraft"
server_type = "cx33"
image = "docker-ce"
labels = {
minecraft = 1
}
location = "nbg1"
public_net {
ipv4_enabled = true
ipv6_enabled = true
}
placement_group_id = 0
ssh_keys = [
hcloud_ssh_key.mckey.name,
]
shutdown_before_deletion = true
user_data = templatefile("cloud-init.yml",
{
volume_path = "/dev/sdb",
docker-compose = base64gzip(file("docker-compose.yml"))
}
)
#dont recreate the server, when cloud-init data changes.
lifecycle {
ignore_changes = [
user_data
]
}
}