Skip to content

Commit 640d1c5

Browse files
arnabadg-googleBBBmau
authored andcommitted
Allow sending false for enabled field under IAP message for resource google_compute_backend_service and resource google_compute_region_backend_service (GoogleCloudPlatform#11907)
1 parent e20c7d3 commit 640d1c5

File tree

4 files changed

+140
-0
lines changed

4 files changed

+140
-0
lines changed

mmv1/products/compute/BackendService.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@ properties:
754754
type: Boolean
755755
description: Whether the serving infrastructure will authenticate and authorize all incoming requests.
756756
required: true
757+
send_empty_value: true
757758
- name: 'oauth2ClientId'
758759
type: String
759760
description: |

mmv1/products/compute/RegionBackendService.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,7 @@ properties:
759759
type: Boolean
760760
description: Whether the serving infrastructure will authenticate and authorize all incoming requests.
761761
required: true
762+
send_empty_value: true
762763
- name: 'oauth2ClientId'
763764
type: String
764765
description: |

mmv1/third_party/terraform/services/compute/resource_compute_backend_service_test.go.tmpl

+67
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,39 @@ func TestAccComputeBackendService_withBackendAndIAP(t *testing.T) {
146146
})
147147
}
148148

149+
func TestAccComputeBackendService_updateIAPEnabled(t *testing.T) {
150+
t.Parallel()
151+
152+
serviceName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10))
153+
154+
acctest.VcrTest(t, resource.TestCase{
155+
PreCheck: func() { acctest.AccTestPreCheck(t) },
156+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
157+
CheckDestroy: testAccCheckComputeBackendServiceDestroyProducer(t),
158+
Steps: []resource.TestStep{
159+
{
160+
Config: testAccComputeBackendService_withIAPEnabled(
161+
serviceName, 10),
162+
},
163+
{
164+
ResourceName: "google_compute_backend_service.lipsum",
165+
ImportState: true,
166+
ImportStateVerify: true,
167+
},
168+
{
169+
Config: testAccComputeBackendService_withIAPDisabled(
170+
serviceName, 10),
171+
},
172+
{
173+
ResourceName: "google_compute_backend_service.lipsum",
174+
ImportState: true,
175+
ImportStateVerify: true,
176+
ImportStateVerifyIgnore: []string{"iap.0.oauth2_client_secret"},
177+
},
178+
},
179+
})
180+
}
181+
149182
func TestAccComputeBackendService_updatePreservesOptionalParameters(t *testing.T) {
150183
t.Parallel()
151184

@@ -1370,6 +1403,40 @@ resource "google_compute_http_health_check" "default" {
13701403
`, serviceName, timeout, igName, itName, checkName)
13711404
}
13721405

1406+
func testAccComputeBackendService_withIAPEnabled(
1407+
serviceName string, timeout int64) string {
1408+
return fmt.Sprintf(`
1409+
resource "google_compute_backend_service" "lipsum" {
1410+
name = "%s"
1411+
description = "Hello World 1234"
1412+
port_name = "http"
1413+
protocol = "HTTP"
1414+
timeout_sec = %v
1415+
1416+
iap {
1417+
enabled = true
1418+
}
1419+
}
1420+
`, serviceName, timeout)
1421+
}
1422+
1423+
func testAccComputeBackendService_withIAPDisabled(
1424+
serviceName string, timeout int64) string {
1425+
return fmt.Sprintf(`
1426+
resource "google_compute_backend_service" "lipsum" {
1427+
name = "%s"
1428+
description = "Hello World 1234"
1429+
port_name = "http"
1430+
protocol = "HTTP"
1431+
timeout_sec = %v
1432+
1433+
iap {
1434+
enabled = false
1435+
}
1436+
}
1437+
`, serviceName, timeout)
1438+
}
1439+
13731440
func testAccComputeBackendService_withSessionAffinity(serviceName, checkName, description, affinityName string) string {
13741441
return fmt.Sprintf(`
13751442
resource "google_compute_backend_service" "foobar" {

mmv1/third_party/terraform/services/compute/resource_compute_region_backend_service_test.go.tmpl

+71
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,39 @@ func TestAccComputeRegionBackendService_withBackendAndIAP(t *testing.T) {
283283
})
284284
}
285285

286+
func TestAccComputeRegionBackendService_updateIAPEnabled(t *testing.T) {
287+
t.Parallel()
288+
289+
serviceName := fmt.Sprintf("foo-%s", acctest.RandString(t, 10))
290+
291+
acctest.VcrTest(t, resource.TestCase{
292+
PreCheck: func() { acctest.AccTestPreCheck(t) },
293+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
294+
CheckDestroy: testAccCheckComputeRegionBackendServiceDestroyProducer(t),
295+
Steps: []resource.TestStep{
296+
{
297+
Config: testAccComputeRegionBackendService_withIAPEnabled(
298+
serviceName, 10),
299+
},
300+
{
301+
ResourceName: "google_compute_region_backend_service.foobar",
302+
ImportState: true,
303+
ImportStateVerify: true,
304+
},
305+
{
306+
Config: testAccComputeRegionBackendService_withIAPDisabled(
307+
serviceName, 10),
308+
},
309+
{
310+
ResourceName: "google_compute_region_backend_service.foobar",
311+
ImportState: true,
312+
ImportStateVerify: true,
313+
ImportStateVerifyIgnore: []string{"iap.0.oauth2_client_secret"},
314+
},
315+
},
316+
})
317+
}
318+
286319
func TestAccComputeRegionBackendService_UDPFailOverPolicyUpdate(t *testing.T) {
287320
t.Parallel()
288321

@@ -1021,6 +1054,44 @@ resource "google_compute_health_check" "zero" {
10211054
`, serviceName, drainingTimeout, checkName)
10221055
}
10231056

1057+
func testAccComputeRegionBackendService_withIAPEnabled(
1058+
serviceName string, timeout int64) string {
1059+
return fmt.Sprintf(`
1060+
resource "google_compute_region_backend_service" "foobar" {
1061+
name = "%s"
1062+
description = "Hello World 1234"
1063+
port_name = "http"
1064+
protocol = "HTTP"
1065+
load_balancing_scheme = "INTERNAL_MANAGED"
1066+
region = "us-central1"
1067+
timeout_sec = %v
1068+
1069+
iap {
1070+
enabled = true
1071+
}
1072+
}
1073+
`, serviceName, timeout)
1074+
}
1075+
1076+
func testAccComputeRegionBackendService_withIAPDisabled(
1077+
serviceName string, timeout int64) string {
1078+
return fmt.Sprintf(`
1079+
resource "google_compute_region_backend_service" "foobar" {
1080+
name = "%s"
1081+
description = "Hello World 1234"
1082+
port_name = "http"
1083+
protocol = "HTTP"
1084+
load_balancing_scheme = "INTERNAL_MANAGED"
1085+
region = "us-central1"
1086+
timeout_sec = %v
1087+
1088+
iap {
1089+
enabled = false
1090+
}
1091+
}
1092+
`, serviceName, timeout)
1093+
}
1094+
10241095
func testAccComputeRegionBackendService_ilbBasicwithIAP(serviceName, checkName string) string {
10251096
return fmt.Sprintf(`
10261097
resource "google_compute_region_backend_service" "foobar" {

0 commit comments

Comments
 (0)