update variables

This commit is contained in:
alessandrovitali committed 2026-09-03 03:52:19 +02:00
1 parent a7102e18ed
commit e0fb97b3ec
2 files changed
+17 -18

No files matched your search

+8 -8
View File
@@ -7,12 +7,12 @@ terraform {
locals {
# single naming scheme - propagates everywhere
key_name = "${var.name}-key"
firewall_name = "${var.name}-fw"
ssh_key_name = "${var.project_name}-key"
firewall_name = "${var.project_name}-fw"
}
resource "hcloud_ssh_key" "this" {
name = local.key_name
name = local.ssh_key_name
public_key = var.ssh_public_key
}
@@ -31,10 +31,10 @@ resource "hcloud_firewall" "this" {
}
resource "hcloud_server" "this" {
name = var.name
image = var.image
server_type = var.server_type
location = var.location
user_data = var.user_data
name = var.project_name
image = var.hcloud_image
server_type = var.hcloud_server_type
location = var.hcloud_location
user_data = var.init_user_data
firewall_ids = [hcloud_firewall.this.id]
}
+9 -10
View File
@@ -1,6 +1,6 @@
variable "name" {
variable "project_name" {
type = string
description = "Host name (used as prefix for the SSH key and firewall)"
description = "Project / host name"
}
variable "ssh_public_key" {
@@ -8,29 +8,28 @@ variable "ssh_public_key" {
description = "Public SSH key to manage the host"
}
variable "server_type" {
variable "hcloud_server_type" {
type = string
description = "Hetzner server type (e.g. cx22)"
}
variable "image" {
variable "hcloud_image" {
type = string
description = "OS image to boot (e.g. debian-13)"
}
variable "location" {
variable "hcloud_location" {
type = string
description = "Hetzner location (fsn1, nbg1, hel1, ash1)"
default = "nbg1"
validation {
condition = contains(["fsn1", "nbg1", "hel1", "ash1"], var.location)
error_message = "location must be one of fsn1, nbg1, hel1, ash1."
condition = contains(["fsn1", "nbg1", "hel1", "ash1"], var.hcloud_location)
error_message = "location must be one of fsn1, nbg1, hel1, ash1"
}
}
variable "user_data" {
variable "init_user_data" {
type = string
description = "Pre-rendered cloud-init user data (optional). Caller renders it from a template."
description = "Pre-rendered cloud-init user data (optional)"
default = null
}