-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
113 lines (101 loc) · 2.87 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
locals {
user_keys_path = "${path.root}/keys/users"
user_keys = { for f in fileset(local.user_keys_path, "*.pub") : trimsuffix(f, ".pub") => file("${local.user_keys_path}/${f}") }
tutanota_records = {
txt-verify = {
type = "TXT"
hostname = "prismlauncher.org"
value = "t-verify=cff46644b119bfd52f571d31f48751d5"
}
spf = {
type = "TXT"
hostname = "prismlauncher.org"
value = "v=spf1 include:spf.tutanota.de -all"
}
dkim1 = {
type = "CNAME"
hostname = "s1._domainkey.prismlauncher.org"
value = "s1.domainkey.tutanota.de"
}
dkim2 = {
type = "CNAME"
hostname = "s2._domainkey.prismlauncher.org"
value = "s2.domainkey.tutanota.de"
}
mta-sts1 = {
type = "CNAME"
hostname = "_mta-sts.prismlauncher.org"
value = "mta-sts.tutanota.de"
}
mta-sts2 = {
type = "CNAME"
hostname = "mta-sts.prismlauncher.org"
value = "mta-sts.tutanota.de"
}
dmarc = {
type = "TXT"
hostname = "_dmarc.prismlauncher.org"
value = "v=DMARC1; p=quarantine; adkim=s"
}
}
}
resource "hcloud_ssh_key" "user_keys" {
for_each = local.user_keys
name = each.key
public_key = each.value
}
resource "hcloud_server" "andesite" {
name = "andesite"
image = "ubuntu-22.04"
server_type = "cax11"
datacenter = "fsn1-dc14"
public_net {
ipv4_enabled = true
ipv6_enabled = true
}
ssh_keys = [for k in hcloud_ssh_key.user_keys : k.id]
lifecycle {
ignore_changes = [ssh_keys]
}
}
resource "netlify_dns_zone" "prismlauncher" {
name = "prismlauncher.org"
lifecycle {
prevent_destroy = true
}
}
resource "netlify_dns_record" "andesite4" {
type = "A"
zone_id = netlify_dns_zone.prismlauncher.id
hostname = "andesite.prismlauncher.org"
value = hcloud_server.andesite.ipv4_address
}
resource "netlify_dns_record" "andesite6" {
type = "AAAA"
zone_id = netlify_dns_zone.prismlauncher.id
hostname = "andesite.prismlauncher.org"
value = hcloud_server.andesite.ipv6_address
}
resource "netlify_dns_record" "tuta_mx" {
type = "MX"
zone_id = netlify_dns_zone.prismlauncher.id
hostname = "prismlauncher.org"
value = "mail.tutanota.de"
priority = 10
}
resource "netlify_dns_record" "tuta_verifications" {
for_each = local.tutanota_records
type = each.value.type
zone_id = netlify_dns_zone.prismlauncher.id
hostname = each.value.hostname
value = each.value.value
}
resource "local_file" "andesite-facts" {
content = jsonencode({
"hostname" = hcloud_server.andesite.name
"domain" = netlify_dns_zone.prismlauncher.name
"ipv4_address" = hcloud_server.andesite.ipv4_address
"ipv6_address" = hcloud_server.andesite.ipv6_address
})
filename = "${path.root}/machines/andesite/facts.json"
}