chore: Restructured infra modules
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
# prod: Traefik, Websites, Bitwarden, RustDesk, status page
|
||||
|
||||
# Port sources: services/prod/*docker-compose.yml (published ports) and services/todo.md
|
||||
# (the documented UFW allow-list).
|
||||
resource "hcloud_firewall" "this" {
|
||||
name = "prod-firewall"
|
||||
|
||||
rule { # server ssh
|
||||
direction = "in"
|
||||
protocol = "tcp"
|
||||
port = "22"
|
||||
source_ips = var.allowed_ssh_source_ips
|
||||
}
|
||||
|
||||
rule { # Traefik http/https (Websites, Bitwarden, status page)
|
||||
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"]
|
||||
}
|
||||
|
||||
rule { # mongo via Traefik tcp entrypoint
|
||||
direction = "in"
|
||||
protocol = "tcp"
|
||||
port = "27017"
|
||||
source_ips = ["0.0.0.0/0", "::/0"]
|
||||
}
|
||||
|
||||
rule { # rustdesk hbbs
|
||||
direction = "in"
|
||||
protocol = "tcp"
|
||||
port = "21115"
|
||||
source_ips = ["0.0.0.0/0", "::/0"]
|
||||
}
|
||||
|
||||
rule {
|
||||
direction = "in"
|
||||
protocol = "tcp"
|
||||
port = "21116"
|
||||
source_ips = ["0.0.0.0/0", "::/0"]
|
||||
}
|
||||
|
||||
rule {
|
||||
direction = "in"
|
||||
protocol = "udp"
|
||||
port = "21116"
|
||||
source_ips = ["0.0.0.0/0", "::/0"]
|
||||
}
|
||||
|
||||
rule { # rustdesk hbbr
|
||||
direction = "in"
|
||||
protocol = "tcp"
|
||||
port = "21117"
|
||||
source_ips = ["0.0.0.0/0", "::/0"]
|
||||
}
|
||||
|
||||
rule {
|
||||
direction = "in"
|
||||
protocol = "tcp"
|
||||
port = "21119"
|
||||
source_ips = ["0.0.0.0/0", "::/0"]
|
||||
}
|
||||
|
||||
rule { # traffic from dev over the private network
|
||||
direction = "in"
|
||||
protocol = "tcp"
|
||||
port = "1-65535"
|
||||
source_ips = [var.network_ip_range]
|
||||
}
|
||||
|
||||
rule {
|
||||
direction = "in"
|
||||
protocol = "udp"
|
||||
port = "1-65535"
|
||||
source_ips = [var.network_ip_range]
|
||||
}
|
||||
}
|
||||
|
||||
resource "hcloud_server" "this" {
|
||||
name = "prod"
|
||||
server_type = var.server_type
|
||||
image = var.image
|
||||
location = var.location
|
||||
ssh_keys = [var.ssh_key_id]
|
||||
firewall_ids = [hcloud_firewall.this.id]
|
||||
|
||||
network {
|
||||
network_id = var.network_id
|
||||
ip = var.private_ip
|
||||
}
|
||||
}
|
||||
|
||||
resource "hcloud_volume" "storage" {
|
||||
name = "prod-storage"
|
||||
size = var.volume_size
|
||||
server_id = hcloud_server.this.id
|
||||
automount = true
|
||||
format = "ext4"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
output "ipv4" {
|
||||
value = hcloud_server.this.ipv4_address
|
||||
}
|
||||
|
||||
output "private_ipv4" {
|
||||
value = var.private_ip
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
variable "server_type" {
|
||||
description = "Server type for prod (Traefik, Websites, Bitwarden, RustDesk, status page)."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "image" {
|
||||
description = "OS image used for the server."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "location" {
|
||||
description = "Hetzner Cloud datacenter location."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "ssh_key_id" {
|
||||
description = "ID of the Hetzner Cloud SSH key to install on the server."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "network_id" {
|
||||
description = "ID of the private network to attach prod to."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "private_ip" {
|
||||
description = "Private network IP for prod."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "volume_size" {
|
||||
description = "Size in GB of the volume attached to prod (disk1 in docs/architecture.md)."
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "allowed_ssh_source_ips" {
|
||||
description = "CIDRs allowed to reach port 22 on prod."
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "network_ip_range" {
|
||||
description = "CIDR of the private network, allowed through the firewall for traffic from dev."
|
||||
type = string
|
||||
}
|
||||
Reference in New Issue
Block a user