IaC for a Tangled Knot
1terraform {
2 required_providers {
3 clouding = {
4 source = "astrojuanlu/clouding"
5 version = "1.0.1"
6 }
7 }
8}
9
10provider "clouding" {}
11
12data "clouding_sshkey" "main" {
13 id = "LQbN5nv9krK9JaeZ"
14}
15
16data "clouding_image" "ubuntu_24_04" {
17 id = "p06Wq42PGkneDVEb"
18}
19
20resource "clouding_firewall" "knot" {
21 name = "Knot Firewall"
22 description = "Firewall rules for Knot server (SSH, Git SSH, Web)"
23}
24
25# Allow SSH (port 22)
26resource "clouding_firewall_rule" "ssh" {
27 firewall_id = clouding_firewall.knot.id
28 description = "Allow SSH"
29 protocol = "tcp"
30 port_range_min = 22
31 port_range_max = 22
32 source_ip = "0.0.0.0/0"
33}
34
35# Allow Git SSH (port 2222)
36resource "clouding_firewall_rule" "git_ssh" {
37 firewall_id = clouding_firewall.knot.id
38 description = "Allow Git SSH"
39 protocol = "tcp"
40 port_range_min = 2222
41 port_range_max = 2222
42 source_ip = "0.0.0.0/0"
43}
44
45# Allow Knot server (port 5555)
46resource "clouding_firewall_rule" "knot_server" {
47 firewall_id = clouding_firewall.knot.id
48 description = "Allow Knot server"
49 protocol = "tcp"
50 port_range_min = 5555
51 port_range_max = 5555
52 source_ip = "0.0.0.0/0"
53}
54
55# Create a server for Knot
56resource "clouding_server" "knot0" {
57 name = "nudo0"
58 hostname = "nudo0"
59 flavor_id = "0.5x1"
60 firewall_id = clouding_firewall.knot.id
61
62 volume = {
63 source = "image"
64 id = data.clouding_image.ubuntu_24_04.id
65 ssd_gb = 20
66 }
67
68 access_configuration = {
69 ssh_key_id = data.clouding_sshkey.main.id
70 }
71
72 enable_strict_antiddos_filtering = false
73
74 # backup_preference = {
75 # frequency = "OneWeek"
76 # slots = 4
77 # }
78
79 # user_data = file("${path.module}/cloud-init.yaml")
80
81 timeouts = {
82 create = "10m"
83 }
84}
85
86output "knot0_ipv4" {
87 value = try(clouding_server.knot0.hostname, "Not yet assigned")
88}