-
Notifications
You must be signed in to change notification settings - Fork 383
Open
Labels
bugSomething isn't workingSomething isn't working
Description
TL;DR
Attempts to update the RegionInstanceGroupManager
used in mig
module fail due to naming collision caused by lifecycle policy create_before_destroy = true
.
Expected behavior
Terraform should be able to re-create the RIGM without collisions (409).
Observed behavior
When applying a change to the RIGM, Terraform concluded that it needs to replace it, tried to create it and errored out because a RIGM with the name already exists.
Terraform Configuration
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "6.45.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = "6.45.0"
}
}
}
locals {
project_id = "..."
region = "europe-west3"
hostname = "host" # apply, then rename to "host2" and apply again
network_project = "..."
subnetwork_name = "..."
}
data "google_compute_subnetwork" "subnetwork" {
name = local.subnetwork_name
project = local.network_project
region = local.region
}
module "instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "13.4.1"
project_id = local.project_id
region = local.region
name_prefix = local.hostname
subnetwork = data.google_compute_subnetwork.subnetwork.self_link
subnetwork_project = local.network_project
}
module "mig" {
source = "terraform-google-modules/vm/google//modules/mig"
version = "13.4.1"
project_id = local.project_id
region = local.region
mig_name = "rigm"
hostname = local.hostname
instance_template = module.instance_template.self_link
}
Terraform Version
Terraform v1.12.2
on linux_amd64
+ provider registry.terraform.io/hashicorp/google v6.45.0
+ provider registry.terraform.io/hashicorp/google-beta v6.45.0
Terraform Provider Versions
Providers required by configuration:
.
├── provider[registry.terraform.io/hashicorp/google-beta] 6.45.0
├── provider[registry.terraform.io/hashicorp/google] 6.45.0
├── module.mig
│ ├── provider[registry.terraform.io/hashicorp/google] >= 4.48.0, < 7.0.0
│ └── provider[registry.terraform.io/hashicorp/google-beta] >= 4.48.0, < 7.0.0
└── module.instance_template
└── provider[registry.terraform.io/hashicorp/google-beta] >= 5.36.0, < 7.0.0
Providers required by state:
provider[registry.terraform.io/hashicorp/google]
provider[registry.terraform.io/hashicorp/google-beta]
Additional information
Applying a change that forces recreation of the google_compute_region_instance_group_manager
resoruce (e.g., changing hostname
from host
to host2
) causes this error:
module.instance_template.google_service_account.sa[0]: Creating...
module.instance_template.google_service_account.sa[0]: Still creating... [00m10s elapsed]
module.instance_template.google_service_account.sa[0]: Creation complete after 14s [id=projects/.../serviceAccounts/host2-europe-west3-sa@....iam.gserviceaccount.com]
module.instance_template.google_compute_instance_template.tpl: Creating...
module.instance_template.google_compute_instance_template.tpl: Creation complete after 3s [id=projects/.../global/instanceTemplates/host2-20250724154627562300000001]
module.mig.google_compute_region_instance_group_manager.mig: Creating...
╷
│ Error: Error creating RegionInstanceGroupManager: googleapi: Error 409: The resource 'projects/.../regions/europe-west3/instanceGroupManagers/rigm' already exists, alreadyExists
│
│ with module.mig.google_compute_region_instance_group_manager.mig,
│ on .terraform/modules/mig/modules/mig/main.tf line 34, in resource "google_compute_region_instance_group_manager" "mig":
│ 34: resource "google_compute_region_instance_group_manager" "mig" {
│
╵
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working