Skip to content

Commit 8fd38b9

Browse files
authored
Add Optional Log Fields to google_cloud_region_backend_service (#13094)
1 parent 2ba1acd commit 8fd38b9

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

mmv1/products/compute/RegionBackendService.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,7 @@ properties:
13731373
at_least_one_of:
13741374
- 'log_config.0.enable'
13751375
- 'log_config.0.sample_rate'
1376+
- 'log_config.0.optional_mode'
13761377
- name: 'sampleRate'
13771378
type: Double
13781379
description: |
@@ -1383,8 +1384,30 @@ properties:
13831384
at_least_one_of:
13841385
- 'log_config.0.enable'
13851386
- 'log_config.0.sample_rate'
1387+
- 'log_config.0.optional_mode'
13861388
diff_suppress_func: 'suppressWhenDisabled'
13871389
default_value: 1.0
1390+
- name: 'optionalMode'
1391+
type: Enum
1392+
description: |
1393+
Specifies the optional logging mode for the load balancer traffic.
1394+
Supported values: INCLUDE_ALL_OPTIONAL, EXCLUDE_ALL_OPTIONAL, CUSTOM.
1395+
enum_values:
1396+
- 'INCLUDE_ALL_OPTIONAL'
1397+
- 'EXCLUDE_ALL_OPTIONAL'
1398+
- 'CUSTOM'
1399+
at_least_one_of:
1400+
- 'log_config.0.enable'
1401+
- 'log_config.0.sample_rate'
1402+
- 'log_config.0.optional_mode'
1403+
default_from_api: true
1404+
- name: 'optionalFields'
1405+
type: Array
1406+
description: |
1407+
Specifies the fields to include in logging. This field can only be specified if logging is enabled for this backend service.
1408+
item_type:
1409+
type: String
1410+
default_from_api: true
13881411
- name: 'network'
13891412
type: ResourceRef
13901413
description: |

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

+89
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,37 @@ func TestAccComputeRegionBackendService_subsettingUpdate(t *testing.T) {
390390
}
391391
{{- end }}
392392

393+
func TestAccComputeRegionBackendService_withLogConfig(t *testing.T) {
394+
t.Parallel()
395+
396+
serviceName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10))
397+
checkName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10))
398+
399+
acctest.VcrTest(t, resource.TestCase{
400+
PreCheck: func() { acctest.AccTestPreCheck(t) },
401+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
402+
CheckDestroy: testAccCheckComputeRegionBackendServiceDestroyProducer(t),
403+
Steps: []resource.TestStep{
404+
{
405+
Config: testAccComputeRegionBackendService_withLogConfig(serviceName, checkName),
406+
},
407+
{
408+
ResourceName: "google_compute_region_backend_service.foobar",
409+
ImportState: true,
410+
ImportStateVerify: true,
411+
},
412+
{
413+
Config: testAccComputeRegionBackendService_withLogConfigDisabled(serviceName, checkName),
414+
},
415+
{
416+
ResourceName: "google_compute_region_backend_service.foobar",
417+
ImportState: true,
418+
ImportStateVerify: true,
419+
},
420+
},
421+
})
422+
}
423+
393424
func testAccComputeRegionBackendService_ilbBasic_withUnspecifiedProtocol(serviceName, checkName string) string {
394425
return fmt.Sprintf(`
395426
resource "google_compute_region_backend_service" "foobar" {
@@ -1224,3 +1255,61 @@ resource "google_compute_region_security_policy" "policy" {
12241255
`, serviceName, polLink, polName)
12251256
}
12261257
{{- end }}
1258+
1259+
func testAccComputeRegionBackendService_withLogConfig(serviceName, checkName string) string {
1260+
return fmt.Sprintf(`
1261+
resource "google_compute_region_backend_service" "foobar" {
1262+
name = "%s"
1263+
region = "us-central1"
1264+
health_checks = [google_compute_region_health_check.health_check.self_link]
1265+
protocol = "HTTP"
1266+
load_balancing_scheme = "INTERNAL_MANAGED"
1267+
locality_lb_policy = "ROUND_ROBIN"
1268+
1269+
log_config {
1270+
enable = true
1271+
sample_rate = 1.0
1272+
optional_mode = "INCLUDE_ALL_OPTIONAL"
1273+
}
1274+
}
1275+
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
1281+
1282+
http_health_check {
1283+
port = 80
1284+
}
1285+
}
1286+
`, serviceName, checkName)
1287+
}
1288+
1289+
func testAccComputeRegionBackendService_withLogConfigDisabled(serviceName, checkName string) string {
1290+
return fmt.Sprintf(`
1291+
resource "google_compute_region_backend_service" "foobar" {
1292+
name = "%s"
1293+
region = "us-central1"
1294+
health_checks = [google_compute_region_health_check.health_check.self_link]
1295+
protocol = "HTTP"
1296+
load_balancing_scheme = "INTERNAL_MANAGED"
1297+
locality_lb_policy = "ROUND_ROBIN"
1298+
1299+
log_config {
1300+
enable = false
1301+
}
1302+
}
1303+
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+
1310+
http_health_check {
1311+
port = 80
1312+
}
1313+
}
1314+
`, serviceName, checkName)
1315+
}

0 commit comments

Comments
 (0)