From 7ed37800056e7c53313803fb1d926c37eee232bf Mon Sep 17 00:00:00 2001 From: Michael Lopez Date: Wed, 10 Jul 2024 02:40:42 +0200 Subject: [PATCH] feat(instance_template): supporting template and generated instance description (#388) Co-authored-by: Andrew Peabody Co-authored-by: Awais Malik --- modules/instance_template/README.md | 2 ++ modules/instance_template/main.tf | 2 ++ modules/instance_template/metadata.yaml | 8 ++++++++ modules/instance_template/variables.tf | 12 ++++++++++++ 4 files changed, 24 insertions(+) diff --git a/modules/instance_template/README.md b/modules/instance_template/README.md index 49ed81b9..1d8045e8 100644 --- a/modules/instance_template/README.md +++ b/modules/instance_template/README.md @@ -20,6 +20,7 @@ See the [simple](../../examples/instance_template/simple) for a usage example. | auto\_delete | Whether or not the boot disk should be auto-deleted | `string` | `"true"` | no | | automatic\_restart | (Optional) Specifies whether the instance should be automatically restarted if it is terminated by Compute Engine (not terminated by a user). | `bool` | `true` | no | | can\_ip\_forward | Enable IP forwarding, for NAT instances for example | `string` | `"false"` | no | +| description | The template's description | `string` | `""` | no | | disk\_encryption\_key | The id of the encryption key that is stored in Google Cloud KMS to use to encrypt all the disks on this instance | `string` | `null` | no | | disk\_labels | Labels to be assigned to boot disk, provided as a map | `map(string)` | `{}` | no | | disk\_resource\_policies | A list (short name or id) of resource policies to attach to this disk for automatic snapshot creations | `list(string)` | `[]` | no | @@ -29,6 +30,7 @@ See the [simple](../../examples/instance_template/simple) for a usage example. | enable\_nested\_virtualization | Defines whether the instance should have nested virtualization enabled. | `bool` | `false` | no | | enable\_shielded\_vm | Whether to enable the Shielded VM configuration on the instance. Note that the instance image must support Shielded VMs. See https://cloud.google.com/compute/docs/images | `bool` | `false` | no | | gpu | GPU information. Type and count of GPU to attach to the instance template. See https://cloud.google.com/compute/docs/gpus more details |
object({
type = string
count = number
})
| `null` | no | +| instance\_description | Description of the generated instances | `string` | `""` | no | | ipv6\_access\_config | IPv6 access configurations. Currently a max of 1 IPv6 access configuration is supported. If not specified, the instance will have no external IPv6 Internet access. |
list(object({
network_tier = string
}))
| `[]` | no | | labels | Labels, provided as a map | `map(string)` | `{}` | no | | machine\_type | Machine type to create, e.g. n1-standard-1 | `string` | `"n1-standard-1"` | no | diff --git a/modules/instance_template/main.tf b/modules/instance_template/main.tf index b8985425..9971fd61 100644 --- a/modules/instance_template/main.tf +++ b/modules/instance_template/main.tf @@ -66,6 +66,8 @@ locals { resource "google_compute_instance_template" "tpl" { provider = google-beta name_prefix = "${var.name_prefix}-" + description = var.description + instance_description = var.instance_description project = var.project_id machine_type = var.machine_type labels = var.labels diff --git a/modules/instance_template/metadata.yaml b/modules/instance_template/metadata.yaml index 7879f694..6141ce76 100644 --- a/modules/instance_template/metadata.yaml +++ b/modules/instance_template/metadata.yaml @@ -146,6 +146,10 @@ spec: description: Enable IP forwarding, for NAT instances for example varType: string defaultValue: "false" + - name: description + description: The template's description + varType: string + defaultValue: "" - name: disk_encryption_key description: The id of the encryption key that is stored in Google Cloud KMS to use to encrypt all the disks on this instance varType: string @@ -184,6 +188,10 @@ spec: type = string count = number }) + - name: instance_description + description: Description of the generated instances + varType: string + defaultValue: "" - name: ipv6_access_config description: IPv6 access configurations. Currently a max of 1 IPv6 access configuration is supported. If not specified, the instance will have no external IPv6 Internet access. varType: |- diff --git a/modules/instance_template/variables.tf b/modules/instance_template/variables.tf index 86c4baf2..45528f68 100644 --- a/modules/instance_template/variables.tf +++ b/modules/instance_template/variables.tf @@ -26,6 +26,18 @@ variable "name_prefix" { default = "default-instance-template" } +variable "description" { + description = "The template's description" + type = string + default = "" +} + +variable "instance_description" { + description = "Description of the generated instances" + type = string + default = "" +} + variable "machine_type" { description = "Machine type to create, e.g. n1-standard-1" type = string