-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
118 lines (108 loc) · 2.2 KB
/
main.tf
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
terraform {
required_providers {
hcloud = {
source = "hetznercloud/hcloud"
version = "1.25.1"
}
}
}
variable "hcloud_token" {}
locals {
ssh_keys = ["mrcage"]
location = "nbg1"
}
provider "hcloud" {
token = var.hcloud_token
}
resource "hcloud_firewall" "web_fw" {
name = "web-fw"
rule {
direction = "in"
protocol = "icmp"
source_ips = [
"0.0.0.0/0",
"::/0"
]
}
rule {
direction = "in"
protocol = "tcp"
port = 22
source_ips = [
"0.0.0.0/0",
"::/0"
]
}
rule {
direction = "in"
protocol = "tcp"
port = 80
source_ips = [
"0.0.0.0/0",
"::/0"
]
}
rule {
direction = "in"
protocol = "tcp"
port = 443
source_ips = [
"0.0.0.0/0",
"::/0"
]
}
}
resource "hcloud_server" "round20" {
name = "round20.etoa.net"
image = "ubuntu-18.04"
server_type = "cx11"
location = local.location
ssh_keys = local.ssh_keys
user_data = templatefile("cloud_config.yaml", {
hostname = "round20.etoa.net"
public_ip = "78.47.232.230"
webapp_branch = "3.6-stable"
data_disk = hcloud_volume.round20_data.linux_device
})
firewall_ids = [hcloud_firewall.web_fw.id]
depends_on = [
hcloud_volume.round20_data,
]
}
resource "hcloud_volume" "round20_data" {
name = "round20-data"
size = 10
location = local.location
format = "ext4"
}
resource "hcloud_volume_attachment" "round20_data" {
volume_id = hcloud_volume.round20_data.id
server_id = hcloud_server.round20.id
}
resource "hcloud_server" "test" {
name = "test.etoa.net"
image = "ubuntu-18.04"
server_type = "cx11"
location = local.location
ssh_keys = local.ssh_keys
user_data = templatefile("cloud_config.yaml", {
hostname = "test.etoa.net"
public_ip = "116.202.178.35"
webapp_branch = "master"
data_disk = hcloud_volume.test_data.linux_device
})
firewall_ids = [hcloud_firewall.web_fw.id]
depends_on = [
hcloud_volume.test_data,
]
}
resource "hcloud_volume" "test_data" {
name = "test-data"
size = 10
location = local.location
format = "ext4"
}
resource "hcloud_volume_attachment" "test_data" {
volume_id = hcloud_volume.test_data.id
server_id = hcloud_server.test.id
}