Code Monkey home page Code Monkey logo

Comments (6)

ggtisc avatar ggtisc commented on June 1, 2024 1

Thanks for the update! Yeah, this solution looks good for you GoogleCloudPlatform/magic-modules#10214

So, are you ok right now, or do you still have issues?

from terraform-provider-google.

ggtisc avatar ggtisc commented on June 1, 2024

Hi @dullest with the steps to reproduce the issue 1st both resources were created, then 1 env variable was removed and finally the change was applied. So are you expecting that the env vars that aren't removed change their values? Because the unique change is that 1 env var was removed from both resources, but for the other variables their values remain.

from terraform-provider-google.

dullest avatar dullest commented on June 1, 2024

I'm expecting env blocks work as a set instead of a list in order to avoid unnecessary diffs.
I confirmed with fixed provider binary on my local with this change that the type change from a list to a set fixes the issue.

Let me simplify the behaviors and the steps a bit.

Actual Behavior and the steps
  1. applying this resource with 4 env blocks
resource "google_cloud_run_v2_service" "default" {
  name     = "test"
  location = "asia-northeast1"

  template {
    containers {
      image = "docker/welcome-to-docker"

      ports {
        container_port = 80
      }

      env {
        name  = "FOO1"
        value = "bar1"
      }

      env {
        name  = "FOO2"
        value = "bar2"
      }

      env {
        name  = "FOO3"
        value = "bar3"
      }

      env {
        name  = "FOO4"
        value = "bar4"
      }
    }
  }
}
  1. removing one env block (commented out FOO2)
resource "google_cloud_run_v2_service" "default" {
  name     = "test"
  location = "asia-northeast1"

  template {
    containers {
      image = "docker/welcome-to-docker"

      ports {
        container_port = 80
      }

      env {
        name  = "FOO1"
        value = "bar1"
      }

      # env {
      #   name  = "FOO2"
      #   value = "bar2"
      # }

      env {
        name  = "FOO3"
        value = "bar3"
      }

      env {
        name  = "FOO4"
        value = "bar4"
      }
    }
  }
}
  1. applying again shows following diff (current behavior)
    It shows FOO3, FOO4 are also recognized as the diff even I didn't change
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # google_cloud_run_v2_service.default will be updated in-place
  ~ resource "google_cloud_run_v2_service" "default" {
        id                      = "redacted"
        name                    = "test"
        # (25 unchanged attributes hidden)

      ~ template {
            # (6 unchanged attributes hidden)

          ~ containers {
                # (4 unchanged attributes hidden)

              ~ env {
                  ~ name  = "FOO2" -> "FOO3"
                  ~ value = "bar2" -> "bar3"
                }
              ~ env {
                  ~ name  = "FOO3" -> "FOO4"
                  ~ value = "bar3" -> "bar4"
                }
              - env {
                  - name  = "FOO4" -> null
                  - value = "bar4" -> null
                }

                # (4 unchanged blocks hidden)
            }

            # (1 unchanged block hidden)
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
Expected Behavior and the steps
  1. applying this resource with 4 env blocks
resource "google_cloud_run_v2_service" "default" {
  name     = "test"
  location = "asia-northeast1"

  template {
    containers {
      image = "docker/welcome-to-docker"

      ports {
        container_port = 80
      }

      env {
        name  = "FOO1"
        value = "bar1"
      }

      env {
        name  = "FOO2"
        value = "bar2"
      }

      env {
        name  = "FOO3"
        value = "bar3"
      }

      env {
        name  = "FOO4"
        value = "bar4"
      }
    }
  }
}
  1. removing one env block (commented out FOO2)
resource "google_cloud_run_v2_service" "default" {
  name     = "test"
  location = "asia-northeast1"

  template {
    containers {
      image = "docker/welcome-to-docker"

      ports {
        container_port = 80
      }

      env {
        name  = "FOO1"
        value = "bar1"
      }

      # env {
      #   name  = "FOO2"
      #   value = "bar2"
      # }

      env {
        name  = "FOO3"
        value = "bar3"
      }

      env {
        name  = "FOO4"
        value = "bar4"
      }
    }
  }
}
  1. applying again shows following diff
    It only shows FOO2 is the diff, not like actual behavior showed FOO3, FOO4 are also the diff
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:- hashicorp/google in /Users/dullest/go/1.21.7/bin
│  - hashicorp/google-beta in /Users/dullest/go/1.21.7/bin
│ 
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with
│ published releases.data.google_project.project: Reading...
google_cloud_run_v2_service.default: Refreshing state... [id=redacted]
data.google_project.project: Read complete after 2s [id=redacted]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # google_cloud_run_v2_service.default will be updated in-place
  ~ resource "google_cloud_run_v2_service" "default" {
        id                      = "redacted"
        name                    = "test"
        # (25 unchanged attributes hidden)

      ~ template {
            # (6 unchanged attributes hidden)

          ~ containers {
                # (4 unchanged attributes hidden)

              - env {
                  - name  = "FOO2" -> null
                  - value = "bar2" -> null
                }

                # (6 unchanged blocks hidden)
            }

            # (1 unchanged block hidden)
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

from terraform-provider-google.

dullest avatar dullest commented on June 1, 2024

I'm ok right now. I'll wait the release which will have the fix.

from terraform-provider-google.

ggtisc avatar ggtisc commented on June 1, 2024

@rileykarson could you please help closing this issue?

from terraform-provider-google.

rileykarson avatar rileykarson commented on June 1, 2024

Added to our major release milestone, so that this gets accounted for during that. GoogleCloudPlatform/magic-modules#10214 is an outstanding PR to resolve.

from terraform-provider-google.

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.