-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
118 lines (101 loc) · 2.02 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
variable "hcloud_token" {
sensitive = true
type = string
}
variable "hetznerdns_token" {
sensitive = true
type = string
}
# Configure the Hetzner Cloud Provider
terraform {
required_version = ">= 1.0"
required_providers {
hcloud = {
source = "hetznercloud/hcloud"
version = "1.45.0"
}
hetznerdns = {
source = "timohirt/hetznerdns"
version = "2.2.0"
}
}
cloud {
organization = "nevarro"
workspaces {
name = "infrastructure"
}
}
}
provider "hcloud" {
token = var.hcloud_token
}
provider "hetznerdns" {
apitoken = var.hetznerdns_token
}
# SSH Keys
resource "hcloud_ssh_key" "tatooine_ssh_key" {
name = "sumner@tatooine"
public_key = file("./ssh-pubkeys/tatooine.pub")
}
resource "hcloud_ssh_key" "coruscant_ssh_key" {
name = "sumner@coruscant"
public_key = file("./ssh-pubkeys/coruscant.pub")
}
resource "hcloud_ssh_key" "scarif_ssh_key" {
name = "sumner@scarif"
public_key = file("./ssh-pubkeys/scarif.pub")
}
# Firewalls
resource "hcloud_firewall" "web_server_firewall" {
name = "web-server"
rule {
description = "ping"
direction = "in"
protocol = "icmp"
source_ips = [
"0.0.0.0/0",
"::/0"
]
}
rule {
description = "SSH"
direction = "in"
protocol = "tcp"
port = "22"
source_ips = [
"0.0.0.0/0",
"::/0"
]
}
rule {
description = "HTTP"
direction = "in"
protocol = "tcp"
port = "80"
source_ips = [
"0.0.0.0/0",
"::/0"
]
}
rule {
description = "HTTPS"
direction = "in"
protocol = "tcp"
port = "443"
source_ips = [
"0.0.0.0/0",
"::/0"
]
}
}
# Private Networks
resource "hcloud_network" "nevarro_network" {
name = "nevarro"
ip_range = "10.0.0.0/8"
}
resource "hcloud_network_subnet" "nevarronet" {
network_id = hcloud_network.nevarro_network.id
type = "cloud"
network_zone = "us-east"
ip_range = "10.0.1.0/24"
}