From 836ef7942a4fd0df8acee49f1f97541a6b556395 Mon Sep 17 00:00:00 2001 From: Michael Lopez Date: Tue, 19 Mar 2024 14:35:27 +0100 Subject: [PATCH 1/2] Supporting template and generated instance description --- modules/instance_template/README.md | 2 ++ modules/instance_template/main.tf | 2 ++ modules/instance_template/variables.tf | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/modules/instance_template/README.md b/modules/instance_template/README.md index 2b39fee6..6017c6d6 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\_size\_gb | Boot disk size in GB | `string` | `"100"` | no | @@ -28,6 +29,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 573a0e22..4d11fb8d 100644 --- a/modules/instance_template/main.tf +++ b/modules/instance_template/main.tf @@ -65,6 +65,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/variables.tf b/modules/instance_template/variables.tf index 2efa8608..bc866a6f 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 From f31835e769319c369d1868263e7c0107fde3d311 Mon Sep 17 00:00:00 2001 From: Awais Malik Date: Tue, 9 Jul 2024 16:53:17 -0700 Subject: [PATCH 2/2] generated docs --- modules/instance_template/README.md | 4 ++-- modules/instance_template/metadata.yaml | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/instance_template/README.md b/modules/instance_template/README.md index a68b23fd..1d8045e8 100644 --- a/modules/instance_template/README.md +++ b/modules/instance_template/README.md @@ -20,7 +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 | +| 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 | @@ -30,7 +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 | +| 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/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: |-