-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
61 lines (53 loc) · 1.54 KB
/
main.tf
File metadata and controls
61 lines (53 loc) · 1.54 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
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}") }
}
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 "cloudflare_dns_record" "andesite4" {
zone_id = var.zone_id
name = "andesite.prismlauncher.org"
content = hcloud_server.andesite.ipv4_address
type = "A"
ttl = 1
}
resource "cloudflare_dns_record" "andesite6" {
zone_id = var.zone_id
name = "andesite.prismlauncher.org"
content = hcloud_server.andesite.ipv6_address
type = "AAAA"
ttl = 1
}
resource "cloudflare_dns_record" "prometheus_andesite" {
zone_id = var.zone_id
name = "prometheus.andesite.prismlauncher.org"
content = "andesite.prismlauncher.org"
type = "CNAME"
ttl = 1
}
resource "local_file" "andesite-facts" {
content = jsonencode({
"hostname" = hcloud_server.andesite.name
"domain" = var.domain
"ipv4_address" = hcloud_server.andesite.ipv4_address
"ipv6_address" = hcloud_server.andesite.ipv6_address
})
filename = "${path.root}/nix/modules/system-andesite/networking.json"
}