Skip to content

Commit 6042c8c

Browse files
authored
Added IAP Enable/Disable flag in cloudrunv2 service. (#13575)
1 parent 43529e6 commit 6042c8c

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed

mmv1/products/cloudrunv2/Service.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ examples:
172172
'zip_path': '"./test-fixtures/function-source.zip"'
173173
ignore_read_extra:
174174
- 'deletion_protection'
175+
- name: 'cloudrunv2_service_iap'
176+
primary_resource_id: 'default'
177+
primary_resource_name: 'fmt.Sprintf("tf-test-cloudrun-iap-service%s", context["random_suffix"])'
178+
min_version: 'beta'
179+
vars:
180+
cloud_run_service_name: 'cloudrun-iap-service'
181+
ignore_read_extra:
182+
- 'deletion_protection'
175183
virtual_fields:
176184
- name: 'deletion_protection'
177185
description: |
@@ -1214,3 +1222,8 @@ properties:
12141222
description: |
12151223
A system-generated fingerprint for this version of the resource. May be used to detect modification conflict during updates.
12161224
output: true
1225+
- name: 'iapEnabled'
1226+
type: Boolean
1227+
description: |
1228+
Used to enable/disable IAP for the service.
1229+
min_version: 'beta'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
resource "google_cloud_run_v2_service" "{{$.PrimaryResourceId}}" {
2+
provider = google-beta
3+
name = "{{index $.Vars "cloud_run_service_name"}}"
4+
location = "us-central1"
5+
deletion_protection = false
6+
ingress = "INGRESS_TRAFFIC_ALL"
7+
launch_stage = "BETA"
8+
iap_enabled = true
9+
10+
template {
11+
containers {
12+
image = "us-docker.pkg.dev/cloudrun/container/hello"
13+
}
14+
}
15+
}
16+

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

+75
Original file line numberDiff line numberDiff line change
@@ -1557,3 +1557,78 @@ resource "google_project_iam_member" "logs_writer" {
15571557
}
15581558
`, context)
15591559
}
1560+
1561+
{{ if ne $.TargetVersionName `ga` -}}
1562+
func TestAccCloudRunV2Service_cloudrunv2ServiceIapUpdate(t *testing.T) {
1563+
t.Parallel()
1564+
1565+
context := map[string]interface{}{
1566+
"random_suffix": acctest.RandString(t, 10),
1567+
}
1568+
1569+
acctest.VcrTest(t, resource.TestCase{
1570+
PreCheck: func() { acctest.AccTestPreCheck(t) },
1571+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
1572+
CheckDestroy: testAccCheckCloudRunV2ServiceDestroyProducer(t),
1573+
Steps: []resource.TestStep{
1574+
{
1575+
Config: testAccCloudRunV2Service_cloudrunv2ServiceIap(context),
1576+
},
1577+
{
1578+
ResourceName: "google_cloud_run_v2_service.default",
1579+
ImportState: true,
1580+
ImportStateVerify: true,
1581+
ImportStateVerifyIgnore: []string{"annotations", "deletion_protection", "labels", "location", "name", "terraform_labels"},
1582+
},
1583+
{
1584+
Config: testAccCloudRunV2Service_cloudrunv2ServiceIapUpdate(context),
1585+
},
1586+
{
1587+
ResourceName: "google_cloud_run_v2_service.default",
1588+
ImportState: true,
1589+
ImportStateVerify: true,
1590+
ImportStateVerifyIgnore: []string{"annotations", "deletion_protection", "labels", "location", "name", "terraform_labels"},
1591+
},
1592+
},
1593+
})
1594+
}
1595+
1596+
func testAccCloudRunV2Service_cloudrunv2ServiceIap(context map[string]interface{}) string {
1597+
return acctest.Nprintf(`
1598+
resource "google_cloud_run_v2_service" "default" {
1599+
provider = google-beta
1600+
name = "tf-test-cloudrun-iap-service%{random_suffix}"
1601+
location = "us-central1"
1602+
deletion_protection = false
1603+
ingress = "INGRESS_TRAFFIC_ALL"
1604+
launch_stage = "BETA"
1605+
iap_enabled = true
1606+
1607+
template {
1608+
containers {
1609+
image = "us-docker.pkg.dev/cloudrun/container/hello"
1610+
}
1611+
}
1612+
}
1613+
`, context)
1614+
}
1615+
1616+
func testAccCloudRunV2Service_cloudrunv2ServiceIapUpdate(context map[string]interface{}) string {
1617+
return acctest.Nprintf(`
1618+
resource "google_cloud_run_v2_service" "default" {
1619+
provider = google-beta
1620+
name = "tf-test-cloudrun-iap-service%{random_suffix}"
1621+
location = "us-central1"
1622+
deletion_protection = false
1623+
ingress = "INGRESS_TRAFFIC_ALL"
1624+
iap_enabled = false
1625+
1626+
template {
1627+
containers {
1628+
image = "us-docker.pkg.dev/cloudrun/container/hello"
1629+
}
1630+
}
1631+
}
1632+
`, context)
1633+
}
1634+
{{- end }}

0 commit comments

Comments
 (0)