From c4262c5b75168c0d4dd07da8bedcec973795146f Mon Sep 17 00:00:00 2001 From: Pavel Korzhenko Date: Mon, 21 Oct 2019 04:35:59 -0400 Subject: [PATCH 1/5] issue #28 - RegionInstanceGroupManager is forced to be re-created - fix. --- modules/mig/main.tf | 2 ++ modules/mig_with_percent/main.tf | 1 + 2 files changed, 3 insertions(+) diff --git a/modules/mig/main.tf b/modules/mig/main.tf index ac997709..3251249a 100644 --- a/modules/mig/main.tf +++ b/modules/mig/main.tf @@ -56,6 +56,7 @@ resource "google_compute_region_instance_group_manager" "mig" { health_check = length(local.healthchecks) > 0 ? local.healthchecks[0] : "" initial_delay_sec = length(local.healthchecks) > 0 ? var.hc_initial_delay_sec : 0 } + distribution_policy_zones = local.distribution_policy_zones dynamic "update_policy" { for_each = var.update_policy @@ -72,6 +73,7 @@ resource "google_compute_region_instance_group_manager" "mig" { lifecycle { create_before_destroy = "true" + ignore_changes = ["distribution_policy_zones"] } } diff --git a/modules/mig_with_percent/main.tf b/modules/mig_with_percent/main.tf index d74b8499..cf048c69 100644 --- a/modules/mig_with_percent/main.tf +++ b/modules/mig_with_percent/main.tf @@ -82,6 +82,7 @@ resource "google_compute_region_instance_group_manager" "mig_with_percent" { lifecycle { create_before_destroy = "true" + ignore_changes = ["distribution_policy_zones"] } } From ffa69916cc1f54603da9cc2523fbea9a083df968 Mon Sep 17 00:00:00 2001 From: Pavel Korzhenko Date: Fri, 25 Oct 2019 02:37:57 -0400 Subject: [PATCH 2/5] issue #28 - RegionInstanceGroupManager is forced to be re-created - fix. --- CHANGELOG.md | 9 +++++++++ README.md | 5 +++++ modules/mig/main.tf | 5 ++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d02e4a81..18a99219 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [1.1.1] - 2019-10-25 + +### Fixed + +- `distribution_policy_zones` ignoring [#37] + +## [1.1.0] - 2019-10-23 + ### Added - Added variable `project_id`. [#26] @@ -45,3 +53,4 @@ project adheres to [Semantic Versioning](http://semver.org/). [#16]: https://github.com/terraform-google-modules/terraform-google-vm/pull/16 [#18]: https://github.com/terraform-google-modules/terraform-google-vm/pull/18 [#26]: https://github.com/terraform-google-modules/terraform-google-vm/pull/26 +[#37]: https://github.com/terraform-google-modules/terraform-google-vm/pull/37 \ No newline at end of file diff --git a/README.md b/README.md index 844922fb..c7d0309e 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,11 @@ The following APIs must be enabled on your project: See also the [project_services](modules/project_services) module (optional). +## Notes + +`distribution_policy_zones` cannot be changed during use. If you have changed them yourself or +used to a default value, then you'll have to force recreate a mig group yourself. + ## Test Configuration 1. Create a `terraform.tfvars` file, using `terraform.tfvars.example` as an example diff --git a/modules/mig/main.tf b/modules/mig/main.tf index 3251249a..bd4e065c 100644 --- a/modules/mig/main.tf +++ b/modules/mig/main.tf @@ -20,8 +20,8 @@ locals { google_compute_health_check.tcp_healthcheck.*.self_link, ) distribution_policy_zones_base = { - default = data.google_compute_zones.available.names - user = var.distribution_policy_zones + default = data.google_compute_zones.available.names + user = var.distribution_policy_zones } distribution_policy_zones = local.distribution_policy_zones_base[length(var.distribution_policy_zones) == 0 ? "default" : "user"] } @@ -143,4 +143,3 @@ resource "google_compute_health_check" "tcp_healthcheck" { port = var.hc_port } } - From b1796f19c391a5cf7b82f4938d0224644bbdb45f Mon Sep 17 00:00:00 2001 From: Pavel Korzhenko Date: Fri, 25 Oct 2019 02:39:10 -0400 Subject: [PATCH 3/5] issue #28 - RegionInstanceGroupManager is forced to be re-created - fix. --- modules/mig/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/mig/main.tf b/modules/mig/main.tf index bd4e065c..db64ae04 100644 --- a/modules/mig/main.tf +++ b/modules/mig/main.tf @@ -20,8 +20,8 @@ locals { google_compute_health_check.tcp_healthcheck.*.self_link, ) distribution_policy_zones_base = { - default = data.google_compute_zones.available.names - user = var.distribution_policy_zones + default = data.google_compute_zones.available.names + user = var.distribution_policy_zones } distribution_policy_zones = local.distribution_policy_zones_base[length(var.distribution_policy_zones) == 0 ? "default" : "user"] } From 95e5d8d37c89b2fcee3aa623eac67647fad17a63 Mon Sep 17 00:00:00 2001 From: Pavel Korzhenko Date: Fri, 25 Oct 2019 11:19:17 -0400 Subject: [PATCH 4/5] Update README.md Co-Authored-By: Morgante Pell --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c7d0309e..eb0ad7df 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ See also the [project_services](modules/project_services) module (optional). ## Notes `distribution_policy_zones` cannot be changed during use. If you have changed them yourself or -used to a default value, then you'll have to force recreate a mig group yourself. +used to have a default value, then you'll have to force recreate a MIG group yourself. ## Test Configuration From c522daa532496ed1a9ed25669cbe08d79e0078e7 Mon Sep 17 00:00:00 2001 From: Pavel Korzhenko Date: Fri, 25 Oct 2019 11:19:33 -0400 Subject: [PATCH 5/5] Update CHANGELOG.md Co-Authored-By: Morgante Pell --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18a99219..1230b4c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ project adheres to [Semantic Versioning](http://semver.org/). ### Fixed -- `distribution_policy_zones` ignoring [#37] +- Fix bug with `distribution_policy_zones` forcing permadiff. [#37] ## [1.1.0] - 2019-10-23 @@ -53,4 +53,4 @@ project adheres to [Semantic Versioning](http://semver.org/). [#16]: https://github.com/terraform-google-modules/terraform-google-vm/pull/16 [#18]: https://github.com/terraform-google-modules/terraform-google-vm/pull/18 [#26]: https://github.com/terraform-google-modules/terraform-google-vm/pull/26 -[#37]: https://github.com/terraform-google-modules/terraform-google-vm/pull/37 \ No newline at end of file +[#37]: https://github.com/terraform-google-modules/terraform-google-vm/pull/37