Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support service-level min instances in Cloud Run v2 services. #10083

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions mmv1/products/cloudrunv2/Service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ properties:
One or more custom audiences that you want this service to support. Specify each custom audience as the full URL in a string. The custom audiences are encoded in the token and used to authenticate requests.
For more information, see https://cloud.google.com/run/docs/configuring/custom-audiences.
item_type: Api::Type::String
- !ruby/object:Api::Type::NestedObject
name: 'scaling'
min_version: beta
description: |
Scaling settings that apply to the whole service
properties:
- !ruby/object:Api::Type::Integer
name: 'minInstanceCount'
description: |
Minimum number of instances for the service, to be divided among all revisions receiving traffic.
- !ruby/object:Api::Type::NestedObject
name: 'template'
required: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,107 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceAttributionLabel(t *testing.T) {
})
}

<% unless version == 'ga' -%>
func TestAccCloudRunV2Service_cloudrunv2ServiceWithServiceMinInstances(t *testing.T) {
t.Parallel()
context := map[string]interface{} {
"random_suffix" : acctest.RandString(t, 10),
}
acctest.VcrTest(t, resource.TestCase {
PreCheck: func() { acctest.AccTestPreCheck(t)},
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckCloudRunV2ServiceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccCloudRunV2Service_cloudrunv2ServiceWithMinInstances(context),
},
{
ResourceName: "google_cloud_run_v2_service.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "launch_stage"},
},
{
Config: testAccCloudRunV2Service_cloudrunv2ServiceWithNoMinInstances(context),
},
{
ResourceName: "google_cloud_run_v2_service.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "launch_stage"},
},

},
})
}

func testAccCloudRunV2Service_cloudrunv2ServiceWithNoMinInstances(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_cloud_run_v2_service" "default" {
name = "tf-test-cloudrun-service%{random_suffix}"
description = "description creating"
location = "us-central1"
launch_stage = "BETA"
annotations = {
generated-by = "magic-modules"
}
ingress = "INGRESS_TRAFFIC_ALL"
labels = {
label-1 = "value-1"
}
client = "client-1"
client_version = "client-version-1"
template {
containers {
name = "container-1"
image = "us-docker.pkg.dev/cloudrun/container/hello"
}
}
lifecycle {
ignore_changes = [
launch_stage,
]
}
}

`, context)
}
func testAccCloudRunV2Service_cloudrunv2ServiceWithMinInstances(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_cloud_run_v2_service" "default" {
name = "tf-test-cloudrun-service%{random_suffix}"
description = "description creating"
location = "us-central1"
launch_stage = "BETA"
annotations = {
generated-by = "magic-modules"
}
ingress = "INGRESS_TRAFFIC_ALL"
labels = {
label-1 = "value-1"
}
client = "client-1"
client_version = "client-version-1"
scaling {
min_instance_count = 1
}
template {
containers {
name = "container-1"
image = "us-docker.pkg.dev/cloudrun/container/hello"
}
}
lifecycle {
ignore_changes = [
launch_stage,
]
}
}

`, context)
}
<% end -%>

func testAccCloudRunV2Service_cloudrunv2ServiceWithAttributionLabel(context map[string]interface{}) string {
return acctest.Nprintf(`
provider "google" {
Expand Down
Loading