infra/terraform/servers.tf
jack 862eac5f11 feat: add Terraform config for Timeweb Cloud infrastructure
Manages main + tools servers and S3 buckets (walava-backup, walava-outline).
Includes mon server resource for import + destroy workflow.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 04:15:27 +07:00

62 lines
1.9 KiB
HCL

# ── Серверы ───────────────────────────────────────────────────────────────────
#
# Первичная настройка (только один раз):
# 1. Узнай ID серверов: my.timeweb.cloud → Серверы → открой сервер → ID в URL
# 2. terraform import twc_server.main <ID>
# 3. terraform import twc_server.tools <ID>
# 4. terraform state show twc_server.main → скопируй cpu/ram/disk/os_id в tfvars
# 5. terraform plan → должно быть "No changes"
#
# Удаление mon:
# 1. terraform import twc_server.mon <ID>
# 2. terraform destroy -target=twc_server.mon
resource "twc_server" "main" {
name = "main"
comment = "Основной: Traefik, Forgejo, Plane, Vaultwarden, Outline, n8n, CI/CD"
location = "ru-1"
os_id = var.server_os_id
cpu = var.main_cpu
ram = var.main_ram
disk_size = var.main_disk_size
disk_type = "nvme"
lifecycle {
prevent_destroy = true
}
}
resource "twc_server" "tools" {
name = "tools"
comment = "Мониторинг: Grafana, Prometheus, Loki, AlertManager, Uptime Kuma"
location = "ru-1"
os_id = var.server_os_id
cpu = var.tools_cpu
ram = var.tools_ram
disk_size = var.tools_disk_size
disk_type = "nvme"
lifecycle {
prevent_destroy = true
}
}
# mon сервер — объявлен только для импорта и удаления через terraform destroy
# После: terraform import twc_server.mon <ID> → terraform destroy -target=twc_server.mon
resource "twc_server" "mon" {
name = "mon"
comment = "DEPRECATED — к удалению"
location = "ru-1"
os_id = var.server_os_id
cpu = 1
ram = 1024
disk_size = 15
disk_type = "nvme"
lifecycle {
prevent_destroy = false
}
}