update variables
This commit is contained in:
1 parent
a7102e18ed
commit
e0fb97b3ec
2 files changed
+17
-18
No files matched your search
@@ -7,12 +7,12 @@ terraform {
|
|||||||
|
|
||||||
locals {
|
locals {
|
||||||
# single naming scheme - propagates everywhere
|
# single naming scheme - propagates everywhere
|
||||||
key_name = "${var.name}-key"
|
ssh_key_name = "${var.project_name}-key"
|
||||||
firewall_name = "${var.name}-fw"
|
firewall_name = "${var.project_name}-fw"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "hcloud_ssh_key" "this" {
|
resource "hcloud_ssh_key" "this" {
|
||||||
name = local.key_name
|
name = local.ssh_key_name
|
||||||
public_key = var.ssh_public_key
|
public_key = var.ssh_public_key
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,10 +31,10 @@ resource "hcloud_firewall" "this" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resource "hcloud_server" "this" {
|
resource "hcloud_server" "this" {
|
||||||
name = var.name
|
name = var.project_name
|
||||||
image = var.image
|
image = var.hcloud_image
|
||||||
server_type = var.server_type
|
server_type = var.hcloud_server_type
|
||||||
location = var.location
|
location = var.hcloud_location
|
||||||
user_data = var.user_data
|
user_data = var.init_user_data
|
||||||
firewall_ids = [hcloud_firewall.this.id]
|
firewall_ids = [hcloud_firewall.this.id]
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
variable "name" {
|
variable "project_name" {
|
||||||
type = string
|
type = string
|
||||||
description = "Host name (used as prefix for the SSH key and firewall)"
|
description = "Project / host name"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "ssh_public_key" {
|
variable "ssh_public_key" {
|
||||||
@@ -8,29 +8,28 @@ variable "ssh_public_key" {
|
|||||||
description = "Public SSH key to manage the host"
|
description = "Public SSH key to manage the host"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "server_type" {
|
variable "hcloud_server_type" {
|
||||||
type = string
|
type = string
|
||||||
description = "Hetzner server type (e.g. cx22)"
|
description = "Hetzner server type (e.g. cx22)"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "image" {
|
variable "hcloud_image" {
|
||||||
type = string
|
type = string
|
||||||
description = "OS image to boot (e.g. debian-13)"
|
description = "OS image to boot (e.g. debian-13)"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "location" {
|
variable "hcloud_location" {
|
||||||
type = string
|
type = string
|
||||||
description = "Hetzner location (fsn1, nbg1, hel1, ash1)"
|
description = "Hetzner location (fsn1, nbg1, hel1, ash1)"
|
||||||
default = "nbg1"
|
|
||||||
validation {
|
validation {
|
||||||
condition = contains(["fsn1", "nbg1", "hel1", "ash1"], var.location)
|
condition = contains(["fsn1", "nbg1", "hel1", "ash1"], var.hcloud_location)
|
||||||
error_message = "location must be one of fsn1, nbg1, hel1, ash1."
|
error_message = "location must be one of fsn1, nbg1, hel1, ash1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "user_data" {
|
variable "init_user_data" {
|
||||||
type = string
|
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
|
default = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user