From cee638b104c023f00ed5ddbe94bb09ce16fd89be Mon Sep 17 00:00:00 2001 From: Jameson Molnar Date: Thu, 11 Jan 2024 11:59:44 -0500 Subject: [PATCH] feat: add variable instance_template_name option --- modules/terraform-zscc-ccvm-gcp/README.md | 3 ++- modules/terraform-zscc-ccvm-gcp/main.tf | 3 ++- modules/terraform-zscc-ccvm-gcp/variables.tf | 10 ++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/terraform-zscc-ccvm-gcp/README.md b/modules/terraform-zscc-ccvm-gcp/README.md index 2ba0d31..a1d6796 100755 --- a/modules/terraform-zscc-ccvm-gcp/README.md +++ b/modules/terraform-zscc-ccvm-gcp/README.md @@ -45,7 +45,8 @@ No modules. | [ccvm\_instance\_type](#input\_ccvm\_instance\_type) | Cloud Connector Instance Type | `string` | `"n2-standard-2"` | no | | [image\_name](#input\_image\_name) | Custom image name to be used for deploying Cloud Connector appliances. Ideally all VMs should be on the same Image as templates always pull the latest from Google Marketplace. This variable is provided if a customer desires to override/retain an old ami for existing deployments rather than upgrading and forcing a replacement. It is also inputted as a list to facilitate if a customer desired to manually upgrade select CCs deployed based on the cc\_count index | `string` | `""` | no | | [instance\_group\_name](#input\_instance\_group\_name) | The name of the Instance Group Manager. Must be 1-63 characters long and comply with RFC1035. Supported characters include lowercase letters, numbers, and hyphens | `list(string)` |
[
""
]
| no | -| [instance\_template\_name\_prefix](#input\_instance\_template\_name\_prefix) | Creates a unique Instance Template name beginning with the specified prefix | `string` | `null` | no | +| [instance\_template\_name](#input\_instance\_template\_name) | The name of the instance template. Conflicts with variable instance\_template\_name\_prefix | `string` | `""` | no | +| [instance\_template\_name\_prefix](#input\_instance\_template\_name\_prefix) | Creates a unique Instance Template name beginning with the specified prefix. Conflicts with variable instance\_template\_name | `string` | `""` | no | | [name\_prefix](#input\_name\_prefix) | A prefix to associate to all the Cloud Connector module resources | `string` | `null` | no | | [project](#input\_project) | Google Cloud project name | `string` | n/a | yes | | [region](#input\_region) | Google Cloud region | `string` | n/a | yes | diff --git a/modules/terraform-zscc-ccvm-gcp/main.tf b/modules/terraform-zscc-ccvm-gcp/main.tf index 9906dab..ef4db90 100755 --- a/modules/terraform-zscc-ccvm-gcp/main.tf +++ b/modules/terraform-zscc-ccvm-gcp/main.tf @@ -2,7 +2,8 @@ # Create Cloud Connector Instance Template ################################################################################ resource "google_compute_instance_template" "cc_instance_template" { - name_prefix = coalesce(var.instance_template_name_prefix, "${var.name_prefix}-cc-template-${var.resource_tag}-") + name_prefix = var.instance_template_name == "" ? coalesce(var.instance_template_name_prefix, "${var.name_prefix}-cc-template-${var.resource_tag}-") : null + name = var.instance_template_name != "" ? var.instance_template_name : null project = var.project region = var.region diff --git a/modules/terraform-zscc-ccvm-gcp/variables.tf b/modules/terraform-zscc-ccvm-gcp/variables.tf index d57417c..2fe6b6c 100755 --- a/modules/terraform-zscc-ccvm-gcp/variables.tf +++ b/modules/terraform-zscc-ccvm-gcp/variables.tf @@ -122,8 +122,14 @@ variable "update_max_unavailable_fixed" { variable "instance_template_name_prefix" { type = string - description = "Creates a unique Instance Template name beginning with the specified prefix" - default = null + description = "Creates a unique Instance Template name beginning with the specified prefix. Conflicts with variable instance_template_name" + default = "" +} + +variable "instance_template_name" { + type = string + description = "The name of the instance template. Conflicts with variable instance_template_name_prefix" + default = "" } variable "instance_group_name" {