Skip to content

Commit 409394a

Browse files
authored
FEAT: Add support for Multi-Region Services in cloudrunv2 (#14592)
1 parent d102272 commit 409394a

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

mmv1/products/cloudrunv2/Service.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,22 @@ properties:
12211221
type: String
12221222
description: |-
12231223
Service account to be used for building the container. The format of this field is `projects/{projectId}/serviceAccounts/{serviceAccountEmail}`.
1224+
- name: 'multiRegionSettings'
1225+
type: NestedObject
1226+
description: |-
1227+
Settings for creating a Multi-Region Service. Make sure to use region = 'global' when using them. For more information, visit https://cloud.google.com/run/docs/multiple-regions#deploy
1228+
properties:
1229+
- name: 'regions'
1230+
type: Array
1231+
item_type:
1232+
type: String
1233+
description: |-
1234+
The list of regions to deploy the multi-region Service.
1235+
- name: 'multiRegionId'
1236+
type: String
1237+
description: |-
1238+
System-generated unique id for the multi-region Service.
1239+
output: true
12241240
- name: 'reconciling'
12251241
type: Boolean
12261242
description: |

mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_service_test.go.tmpl

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,103 @@ resource "google_cloud_run_v2_service" "default" {
13451345
`, context)
13461346
}
13471347

1348+
func TestAccCloudRunV2Service_cloudrunv2MultiRegionService(t *testing.T) {
1349+
t.Parallel()
1350+
context := map[string]interface{} {
1351+
"random_suffix" : acctest.RandString(t, 10),
1352+
}
1353+
acctest.VcrTest(t, resource.TestCase {
1354+
PreCheck: func() { acctest.AccTestPreCheck(t)},
1355+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
1356+
CheckDestroy: testAccCheckCloudRunV2ServiceDestroyProducer(t),
1357+
Steps: []resource.TestStep{
1358+
{
1359+
Config: testAccCloudRunV2Service_cloudrunv2ServiceWithMultiRegion(context),
1360+
},
1361+
{
1362+
ResourceName: "google_cloud_run_v2_service.default",
1363+
ImportState: true,
1364+
ImportStateVerify: true,
1365+
ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "launch_stage", "deletion_protection"},
1366+
},
1367+
{
1368+
Config: testAccCloudRunV2Service_cloudrunv2ServiceWithMultiRegionUpdate(context),
1369+
},
1370+
{
1371+
ResourceName: "google_cloud_run_v2_service.default",
1372+
ImportState: true,
1373+
ImportStateVerify: true,
1374+
ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "launch_stage", "deletion_protection"},
1375+
},
1376+
},
1377+
})
1378+
}
1379+
1380+
func testAccCloudRunV2Service_cloudrunv2ServiceWithMultiRegion(context map[string]interface{}) string {
1381+
return acctest.Nprintf(`
1382+
resource "google_cloud_run_v2_service" "default" {
1383+
name = "tf-test-cloudrun-service%{random_suffix}"
1384+
description = "Multi-Region Service"
1385+
location = "global"
1386+
deletion_protection = false
1387+
launch_stage = "GA"
1388+
annotations = {
1389+
generated-by = "magic-modules"
1390+
}
1391+
multi_region_settings {
1392+
regions = [
1393+
"us-central1",
1394+
"us-east1",
1395+
"us-west1",
1396+
]
1397+
}
1398+
ingress = "INGRESS_TRAFFIC_ALL"
1399+
labels = {
1400+
label-1 = "value-1"
1401+
}
1402+
client = "client-1"
1403+
client_version = "client-version-1"
1404+
template {
1405+
containers {
1406+
image = "us-docker.pkg.dev/cloudrun/container/hello"
1407+
}
1408+
}
1409+
}
1410+
`, context)
1411+
}
1412+
1413+
func testAccCloudRunV2Service_cloudrunv2ServiceWithMultiRegionUpdate(context map[string]interface{}) string {
1414+
return acctest.Nprintf(`
1415+
resource "google_cloud_run_v2_service" "default" {
1416+
name = "tf-test-cloudrun-service%{random_suffix}"
1417+
description = "Multi-Region Service"
1418+
location = "global"
1419+
deletion_protection = false
1420+
launch_stage = "GA"
1421+
annotations = {
1422+
generated-by = "magic-modules"
1423+
}
1424+
multi_region_settings {
1425+
regions = [
1426+
"us-central1",
1427+
"us-east1",
1428+
]
1429+
}
1430+
ingress = "INGRESS_TRAFFIC_ALL"
1431+
labels = {
1432+
label-1 = "value-1"
1433+
}
1434+
client = "client-1"
1435+
client_version = "client-version-1"
1436+
template {
1437+
containers {
1438+
image = "us-docker.pkg.dev/cloudrun/container/hello"
1439+
}
1440+
}
1441+
}
1442+
`, context)
1443+
}
1444+
13481445
func testAccCloudRunV2Service_cloudrunv2ServiceWithGpu(context map[string]interface{}) string {
13491446
return acctest.Nprintf(`
13501447
resource "google_cloud_run_v2_service" "default" {

0 commit comments

Comments
 (0)