From a98a4fbc68a7bf13eb2d30259cfbcd21ccefcd34 Mon Sep 17 00:00:00 2001 From: Viktor Bushmin Date: Mon, 27 Apr 2020 05:56:35 +0300 Subject: [PATCH] Added labels to VPS --- README.md | 1 + main.tf | 1 + modules/hcloud/main.tf | 3 ++- modules/hcloud/variables.tf | 4 ++++ variables.tf | 4 ++++ 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 877a34d..021accb 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ module "hdevs" { vps_list = {"ubuntu_18" = 2} dev_user = "username" hcloud_token = "sdfghj,hgffghjkjhgf" + tags = {"key" = "value"} } output "out" { diff --git a/main.tf b/main.tf index 321bf08..058a75e 100644 --- a/main.tf +++ b/main.tf @@ -11,6 +11,7 @@ module "vps" { vps_list = var.vps_list dev_user = var.dev_user hcloud_token = var.hcloud_token + tags = var.tags } module "dns" { diff --git a/modules/hcloud/main.tf b/modules/hcloud/main.tf index 0ac64ee..4f8d328 100644 --- a/modules/hcloud/main.tf +++ b/modules/hcloud/main.tf @@ -36,5 +36,6 @@ resource "hcloud_server" "dev_vps" { server_type = var.server_type ssh_keys = [ hcloud_ssh_key.dev_ssh_key.id - ] + ] + labels = var.tags } \ No newline at end of file diff --git a/modules/hcloud/variables.tf b/modules/hcloud/variables.tf index 62140d2..eb78d93 100644 --- a/modules/hcloud/variables.tf +++ b/modules/hcloud/variables.tf @@ -45,3 +45,7 @@ variable "server_type" { description = "hcloud server type" default = "cx11" } +variable "tags" { + description = "Tags to VPS. User-defined labels map (key-value pairs)" + type = map(string) +} \ No newline at end of file diff --git a/variables.tf b/variables.tf index 6fde5a5..5ce2113 100644 --- a/variables.tf +++ b/variables.tf @@ -27,4 +27,8 @@ variable "dev_user" { } variable "hcloud_token" { description = "Access token to hcloud API" +} +variable "tags" { + description = "Tags to VPS. User-defined labels map (key-value pairs)" + type = map(string) } \ No newline at end of file