From d96276e1accbac7f95d1b6e60d57618d2e1412c8 Mon Sep 17 00:00:00 2001 From: Jamil Date: Sun, 26 Jan 2025 12:10:34 -0800 Subject: [PATCH] fix(infra): Use naming_suffix in instance_group_manager (#7871) Google still had lingering Relay instance groups and subnets around from a previous deployment that were deleted in the UI and gone, but then popped back up. Theoretically, the instance groups should be deleted because there is no current Terraform config matching them. This change will ensure that instance groups also get rolled over based on the naming suffix introduced in #7870. Related: #7870 --- terraform/environments/production/relays.tf | 18 +++++++++--------- terraform/environments/staging/relays.tf | 18 +++++++++--------- .../modules/google-cloud/apps/relay/main.tf | 4 ++-- .../google-cloud/apps/relay/variables.tf | 6 +++--- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/terraform/environments/production/relays.tf b/terraform/environments/production/relays.tf index 6cf54b861..8a9a827a5 100644 --- a/terraform/environments/production/relays.tf +++ b/terraform/environments/production/relays.tf @@ -353,15 +353,15 @@ module "relays" { zones = ["us-west4-a"] } } - network = google_compute_network.network.self_link - instance_template_naming_suffix = random_string.naming_suffix.result - container_registry = module.google-artifact-registry.url - image_repo = module.google-artifact-registry.repo - image = "relay" - image_tag = local.relay_image_tag - observability_log_level = "info,hyper=off,h2=warn,tower=warn" - application_name = "relay" - application_version = replace(local.relay_image_tag, ".", "-") + network = google_compute_network.network.self_link + naming_suffix = random_string.naming_suffix.result + container_registry = module.google-artifact-registry.url + image_repo = module.google-artifact-registry.repo + image = "relay" + image_tag = local.relay_image_tag + observability_log_level = "info,hyper=off,h2=warn,tower=warn" + application_name = "relay" + application_version = replace(local.relay_image_tag, ".", "-") application_environment_variables = [ { name = "FIREZONE_TELEMETRY" diff --git a/terraform/environments/staging/relays.tf b/terraform/environments/staging/relays.tf index fa31c3418..4e4a97935 100644 --- a/terraform/environments/staging/relays.tf +++ b/terraform/environments/staging/relays.tf @@ -348,15 +348,15 @@ module "relays" { zones = ["us-west4-a"] } } - network = google_compute_network.network.self_link - instance_template_naming_suffix = random_string.naming_suffix.result - container_registry = module.google-artifact-registry.url - image_repo = module.google-artifact-registry.repo - image = "relay" - image_tag = var.image_tag - observability_log_level = "info,hyper=off,h2=warn,tower=warn" - application_name = "relay" - application_version = replace(var.image_tag, ".", "-") + network = google_compute_network.network.self_link + naming_suffix = random_string.naming_suffix.result + container_registry = module.google-artifact-registry.url + image_repo = module.google-artifact-registry.repo + image = "relay" + image_tag = var.image_tag + observability_log_level = "info,hyper=off,h2=warn,tower=warn" + application_name = "relay" + application_version = replace(var.image_tag, ".", "-") application_environment_variables = [ { name = "FIREZONE_TELEMETRY" diff --git a/terraform/modules/google-cloud/apps/relay/main.tf b/terraform/modules/google-cloud/apps/relay/main.tf index 96ada69ef..0d698184f 100644 --- a/terraform/modules/google-cloud/apps/relay/main.tf +++ b/terraform/modules/google-cloud/apps/relay/main.tf @@ -147,7 +147,7 @@ resource "google_compute_instance_template" "application" { project = var.project_id - name_prefix = "${local.application_name}-${each.key}-${var.instance_template_naming_suffix}-" + name_prefix = "${local.application_name}-${each.key}-${var.naming_suffix}-" description = "This template is used to create ${local.application_name} instances using Terraform." @@ -302,7 +302,7 @@ resource "google_compute_region_instance_group_manager" "application" { project = var.project_id - name = "${local.application_name}-group-${each.key}" + name = "${local.application_name}-group-${each.key}-${var.naming_suffix}" base_instance_name = local.application_name diff --git a/terraform/modules/google-cloud/apps/relay/variables.tf b/terraform/modules/google-cloud/apps/relay/variables.tf index a9f9fec81..43b275844 100644 --- a/terraform/modules/google-cloud/apps/relay/variables.tf +++ b/terraform/modules/google-cloud/apps/relay/variables.tf @@ -23,10 +23,10 @@ variable "network" { description = "ID of a Google Cloud Network" } -# Ensure instance group template is recreated when this value is changed. -variable "instance_template_naming_suffix" { +# Ensure instances are recreated when this is changed. +variable "naming_suffix" { type = string - description = "Suffix to append to the name of the instance group template." + description = "Suffix to append to the name of resources." } ################################################################################