hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.33k stars 1.73k forks source link

`google_cloud_run_v2_service` and max_instance_count set to `0` #19178

Open jeremad opened 2 months ago

jeremad commented 2 months ago

Community Note

Terraform Version & Provider Version(s)

Terraform v1.8.3 on linux_amd64

Affected Resource(s)

google_cloud_run_v2_service

Terraform Configuration

resource "google_cloud_run_v2_service" "trader" {
  location     = "europe-west4"
  name         = "example"
  project      = "my_project"
  launch_stage = "GA"

  template {
    execution_environment = "EXECUTION_ENVIRONMENT_GEN2"
    containers {
      image = "europe-west4-docker.pkg.dev/my-project/example/example:latest"

      resources {
        limits = {
          cpu    = "1000m"
          memory = 512 * 1024 * 1024
        }
        cpu_idle = true
      }
    }
    max_instance_request_concurrency = 1000
    scaling {
      min_instance_count = 0
      max_instance_count = *0*
    }
  }
}

Debug Output

No response

Expected Behavior

Either or:

This behavior is documented absolutely nowhere

Actual Behavior

The maximum number of instance is 100

Steps to reproduce

  1. terraform apply

Important Factoids

No response

References

https://cloud.google.com/run/docs/reference/rest/v2/RevisionScaling https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/cloud_run_v2_service#max_instance_count

b/361784995

ggtisc commented 2 months ago

Hi @jeremad!

I'm trying to understand you.

Are you looking for both min_instance_count and max_instance_count values ​​to be equal to 0 when creating a google_cloud_run_v2_service, or some message in the documentation that warns that this is not possible?

jeremad commented 2 months ago

You can ignore the min_instance_count in this issue. When I set max_instance_count to 0, somehow, it's actually set to 100.

ggtisc commented 2 months ago

Confirmed issue!

After executing the code with both values min_instance_count and max_instance_count equal to 0 the max_instance_count is saved in the tfstate file with a value of 100

whaught commented 2 months ago

https://cloud.google.com/run/docs/configuring/max-instances#limits

By default cloud run configures a maximum of 100 instances if the user does not specify any maximum.

jeremad commented 2 months ago

Ok! I missed this in the documentation. That explains part of it, but I would expect the terraform plugin documentation to mention that, since in this case, it's not left out blank, it's explicitly set to another value.