Coder Social home page Coder Social logo

Comments (2)

ogreface avatar ogreface commented on May 23, 2024

Running into this as well.

from terraform-google-vm.

pksmall avatar pksmall commented on May 23, 2024

Hello.

I plunged into this bug so much that I created a test project (https://github.com/pksmall/terraform-google-lb-http-mig).

@ivankorn described the bug in as much detail as possible and I repeated it on my environment:


...
  # module.mig1.google_compute_region_instance_group_manager.mig must be replaced
+/- resource "google_compute_region_instance_group_manager" "mig" {
        base_instance_name        = "multi-mig-lb-http-group1"
      ~ distribution_policy_zones = [
          - "europe-west3-a",
          - "europe-west3-b",
          - "europe-west3-c",
        ] -> (known after apply) # forces replacement
...
           ~ target_size               = 2 -> 0

          + auto_healing_policies {
             + initial_delay_sec = 0
           }

...
  # module.mig2.google_compute_region_instance_group_manager.mig must be replaced
+/- resource "google_compute_region_instance_group_manager" "mig" {
        base_instance_name        = "multi-mig-lb-http-group2"
      ~ distribution_policy_zones = [
          - "us-east1-b",
          - "us-east1-c",
          - "us-east1-d",
        ] -> (known after apply) # forces replacement
...
     + auto_healing_policies {
          + initial_delay_sec = 0
        }
...

Error: Error creating RegionInstanceGroupManager: googleapi: Error 409: The resource 'projects/operating-bolt-254712/regions/us-west1/instanceGroupManagers/multi-mig-lb-http-group3-mig' already exists, alreadyExists

  on ../terraform-google-vm/modules/mig/main.tf line 33, in resource "google_compute_region_instance_group_manager" "mig":
  33: resource "google_compute_region_instance_group_manager" "mig" {

Changes to the local variable distribution_policy_zones result in a forced replacement and change with every apply.

There was a fix to this bug, I thought, but it’s not. Log with edits from @evkuzin:

  # module.mig1.google_compute_region_instance_group_manager.mig must be replaced
+/- resource "google_compute_region_instance_group_manager" "mig" {
        base_instance_name        = "multi-mig-lb-http-group1"
      ~ distribution_policy_zones = [
          - "europe-west3-a",
          - "europe-west3-b",
          - "europe-west3-c",
        ] -> (known after apply) # forces replacement

Error: Error creating RegionInstanceGroupManager: googleapi: Error 409: The resource 'projects/operating-bolt-254712/regions/us-west1/instanceGroupManagers/multi-mig-lb-http-group3-mig' already exists, alreadyExists

  on ../terraform-google-vm/modules/mig/main.tf line 33, in resource "google_compute_region_instance_group_manager" "mig":
  33: resource "google_compute_region_instance_group_manager" "mig" {

Equally, almost only:

          + auto_healing_policies {
             + initial_delay_sec = 0
           }

it has become dynamic.

With my fix log:

..
 # module.mig1.google_compute_region_instance_group_manager.mig will be updated in-place
  ~ resource "google_compute_region_instance_group_manager" "mig" {
        base_instance_name        = "multi-mig-lb-http-group1"
        distribution_policy_zones = [
            "europe-west3-a",
            "europe-west3-b",
            "europe-west3-c",
        ]

 ~ target_size               = 2 -> 0
...
Apply complete! Resources: 0 added, 3 changed, 0 destroyed.

Outputs:

load-balancer-ip = 34.102.215.73

$ ./test.sh 
+ set -e
++ terraform output load-balancer-ip
+ URL=http://34.102.215.73
+ status=0
+ count=0
+ [[ 0 -lt 720 ]]
+ [[ 0 -ne 200 ]]
+ echo 'INFO: Waiting for load balancer...'
INFO: Waiting for load balancer...
++ curl -sf -m 5 -o /dev/null -w '%{http_code}' http://34.102.215.73
+ status=200
+ (( count=count+1 ))
+ sleep 5
+ [[ 1 -lt 720 ]]
+ [[ 200 -ne 200 ]]
+ [[ 1 -lt 720 ]]
+ echo 'INFO: PASS'
INFO: PASS

Bingo. It's worked. And as described in readme we got a response from group#2.

Pull request on the way. Thank you.

p.s. My apologies for the long comment :)

from terraform-google-vm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.