@@ -402,52 +402,14 @@ func TestAccComputeRegionBackendService_withLogConfig(t *testing.T) {
402
402
CheckDestroy: testAccCheckComputeRegionBackendServiceDestroyProducer(t),
403
403
Steps: []resource.TestStep{
404
404
{
405
- // Test: Initial setup with minimal config
406
- Config: testAccComputeRegionBackendService_withLogConfig(serviceName, checkName, 1.0, "INCLUDE_ALL_OPTIONAL"),
405
+ Config: testAccComputeRegionBackendService_withLogConfig(serviceName, checkName),
407
406
},
408
407
{
409
408
ResourceName: "google_compute_region_backend_service.foobar",
410
409
ImportState: true,
411
410
ImportStateVerify: true,
412
411
},
413
412
{
414
- // Test: Update to EXCLUDE_ALL_OPTIONAL mode
415
- Config: testAccComputeRegionBackendService_withLogConfig(serviceName, checkName, 0.5, "EXCLUDE_ALL_OPTIONAL"),
416
- },
417
- {
418
- ResourceName: "google_compute_region_backend_service.foobar",
419
- ImportState: true,
420
- ImportStateVerify: true,
421
- },
422
- {
423
- // Test: Update to CUSTOM mode with fields
424
- Config: testAccComputeRegionBackendService_withLogConfigOptionalFields(serviceName, checkName),
425
- },
426
- {
427
- ResourceName: "google_compute_region_backend_service.foobar",
428
- ImportState: true,
429
- ImportStateVerify: true,
430
- },
431
- {
432
- // Test: CUSTOM mode with empty fields
433
- Config: testAccComputeRegionBackendService_withLogConfigCustomEmpty(serviceName, checkName),
434
- },
435
- {
436
- ResourceName: "google_compute_region_backend_service.foobar",
437
- ImportState: true,
438
- ImportStateVerify: true,
439
- },
440
- {
441
- // Test: Minimum sample rate
442
- Config: testAccComputeRegionBackendService_withLogConfig(serviceName, checkName, 0.0, "INCLUDE_ALL_OPTIONAL"),
443
- },
444
- {
445
- ResourceName: "google_compute_region_backend_service.foobar",
446
- ImportState: true,
447
- ImportStateVerify: true,
448
- },
449
- {
450
- // Test: Disable logging
451
413
Config: testAccComputeRegionBackendService_withLogConfigDisabled(serviceName, checkName),
452
414
},
453
415
{
@@ -1294,85 +1256,29 @@ resource "google_compute_region_security_policy" "policy" {
1294
1256
}
1295
1257
{{- end }}
1296
1258
1297
- func testAccComputeRegionBackendService_withLogConfig(serviceName, checkName string, sampleRate float64, optionalMode string ) string {
1259
+ func testAccComputeRegionBackendService_withLogConfig(serviceName, checkName string) string {
1298
1260
return fmt.Sprintf(`
1299
1261
resource "google_compute_region_backend_service" "foobar" {
1300
1262
name = "%s"
1301
- health_checks = [google_compute_health_check.health_check.self_link]
1302
- port_name = "http"
1303
- protocol = "HTTP"
1304
- load_balancing_scheme = "INTERNAL_MANAGED"
1305
- locality_lb_policy = "ROUND_ROBIN"
1306
-
1307
- log_config {
1308
- enable = true
1309
- sample_rate = %v
1310
- optional_mode = "%s"
1311
- }
1312
- }
1313
-
1314
- resource "google_compute_health_check" "health_check" {
1315
- name = "%s"
1316
- http_health_check {
1317
- port = 80
1318
- }
1319
- }
1320
- `, serviceName, sampleRate, optionalMode, checkName)
1321
- }
1322
-
1323
- func testAccComputeRegionBackendService_withLogConfigOptionalFields(serviceName, checkName string) string {
1324
- return fmt.Sprintf(`
1325
- resource "google_compute_region_backend_service" "foobar" {
1326
- name = "%s"
1327
- health_checks = [google_compute_health_check.health_check.self_link]
1328
- port_name = "http"
1263
+ region = "us-central1"
1264
+ health_checks = [google_compute_region_health_check.health_check.self_link]
1329
1265
protocol = "HTTP"
1330
1266
load_balancing_scheme = "INTERNAL_MANAGED"
1331
1267
locality_lb_policy = "ROUND_ROBIN"
1332
1268
1333
1269
log_config {
1334
1270
enable = true
1335
- sample_rate = 0.5
1336
- optional_mode = "CUSTOM"
1337
- optional_fields = [
1338
- "PROTOCOL",
1339
- "RESPONSE_CODE",
1340
- "REQUEST_METHOD",
1341
- "URL_MAP",
1342
- "BACKEND_TARGET"
1343
- ]
1271
+ sample_rate = 1.0
1272
+ optional_mode = "INCLUDE_ALL_OPTIONAL"
1344
1273
}
1345
1274
}
1346
1275
1347
- resource "google_compute_health_check" "health_check" {
1348
- name = "%s"
1349
- http_health_check {
1350
- port = 80
1351
- }
1352
- }
1353
- `, serviceName, checkName)
1354
- }
1355
-
1356
- func testAccComputeRegionBackendService_withLogConfigCustomEmpty(serviceName, checkName string) string {
1357
- return fmt.Sprintf(`
1358
- resource "google_compute_region_backend_service" "foobar" {
1359
- name = "%s"
1360
- health_checks = [google_compute_health_check.health_check.self_link]
1361
- port_name = "http"
1362
- protocol = "HTTP"
1363
- load_balancing_scheme = "INTERNAL_MANAGED"
1364
- locality_lb_policy = "ROUND_ROBIN"
1365
-
1366
- log_config {
1367
- enable = true
1368
- sample_rate = 0.5
1369
- optional_mode = "CUSTOM"
1370
- optional_fields = []
1371
- }
1372
- }
1276
+ resource "google_compute_region_health_check" "health_check" {
1277
+ name = "%s"
1278
+ region = "us-central1"
1279
+ check_interval_sec = 1
1280
+ timeout_sec = 1
1373
1281
1374
- resource "google_compute_health_check" "health_check" {
1375
- name = "%s"
1376
1282
http_health_check {
1377
1283
port = 80
1378
1284
}
@@ -1384,8 +1290,8 @@ func testAccComputeRegionBackendService_withLogConfigDisabled(serviceName, check
1384
1290
return fmt.Sprintf(`
1385
1291
resource "google_compute_region_backend_service" "foobar" {
1386
1292
name = "%s"
1387
- health_checks = [google_compute_health_check.health_check.self_link]
1388
- port_name = "http"
1293
+ region = "us-central1"
1294
+ health_checks = [google_compute_region_health_check.health_check.self_link]
1389
1295
protocol = "HTTP"
1390
1296
load_balancing_scheme = "INTERNAL_MANAGED"
1391
1297
locality_lb_policy = "ROUND_ROBIN"
@@ -1395,8 +1301,12 @@ resource "google_compute_region_backend_service" "foobar" {
1395
1301
}
1396
1302
}
1397
1303
1398
- resource "google_compute_health_check" "health_check" {
1399
- name = "%s"
1304
+ resource "google_compute_region_health_check" "health_check" {
1305
+ name = "%s"
1306
+ region = "us-central1"
1307
+ check_interval_sec = 1
1308
+ timeout_sec = 1
1309
+
1400
1310
http_health_check {
1401
1311
port = 80
1402
1312
}
0 commit comments