From 6cb381334e0e1697c4044d803312e0ab9431cd70 Mon Sep 17 00:00:00 2001
From: Caio Tavares <89272600+caiotavaresdito@users.noreply.github.com>
Date: Sat, 16 Oct 2021 10:23:11 -0400
Subject: [PATCH] Added dynamic description of compute-vm (#328)
* Added dynamic description of compute-vm
* Re-ordered variables alphabetically
---
modules/compute-vm/README.md | 1 +
modules/compute-vm/main.tf | 6 +++---
modules/compute-vm/variables.tf | 8 +++++++-
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/modules/compute-vm/README.md b/modules/compute-vm/README.md
index 7a1d3e05..e0212328 100644
--- a/modules/compute-vm/README.md
+++ b/modules/compute-vm/README.md
@@ -258,6 +258,7 @@ module "instance-group" {
| *can_ip_forward* | Enable IP forwarding. | bool
| | false
|
| *confidential_compute* | Enable Confidential Compute for these instances. | bool
| | false
|
| *create_template* | Create instance template instead of instances. | bool
| | false
|
+| *description* | Description of a Compute Instance. | string
| | Managed by the compute-vm Terraform module.
|
| *enable_display* | Enable virtual display on the instances | bool
| | false
|
| *encryption* | Encryption options. Only one of kms_key_self_link and disk_encryption_key_raw may be set. If needed, you can specify to encrypt or not the boot disk. | object({...})
| | null
|
| *group* | Define this variable to create an instance group for instances. Disabled for template use. | object({...})
| | null
|
diff --git a/modules/compute-vm/main.tf b/modules/compute-vm/main.tf
index 1941ddfa..1f5866ec 100644
--- a/modules/compute-vm/main.tf
+++ b/modules/compute-vm/main.tf
@@ -122,7 +122,7 @@ resource "google_compute_instance" "default" {
zone = var.zone
name = var.name
hostname = var.hostname
- description = "Managed by the compute-vm Terraform module."
+ description = var.description
tags = var.tags
machine_type = var.instance_type
min_cpu_platform = var.min_cpu_platform
@@ -253,7 +253,7 @@ resource "google_compute_instance_template" "default" {
project = var.project_id
region = local.region
name_prefix = "${var.name}-"
- description = "Managed by the compute-vm Terraform module."
+ description = var.description
tags = var.tags
machine_type = var.instance_type
min_cpu_platform = var.min_cpu_platform
@@ -354,7 +354,7 @@ resource "google_compute_instance_group" "unmanaged" {
)
zone = var.zone
name = var.name
- description = "Terraform-managed."
+ description = var.description
instances = [google_compute_instance.default.0.self_link]
dynamic "named_port" {
for_each = var.group.named_ports != null ? var.group.named_ports : {}
diff --git a/modules/compute-vm/variables.tf b/modules/compute-vm/variables.tf
index 98e7cb2c..00b59c06 100644
--- a/modules/compute-vm/variables.tf
+++ b/modules/compute-vm/variables.tf
@@ -92,7 +92,11 @@ variable "create_template" {
type = bool
default = false
}
-
+variable "description" {
+ description = "Description of a Compute Instance."
+ type = string
+ default = "Managed by the compute-vm Terraform module."
+}
variable "enable_display" {
description = "Enable virtual display on the instances"
type = bool
@@ -243,3 +247,5 @@ variable "zone" {
description = "Compute zone."
type = string
}
+
+