Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add log_config to backend service #2316

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/terraform-beta
18 changes: 18 additions & 0 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,24 @@ objects:
description: |
How many seconds to wait for the backend before considering it a
failed request. Default is 30 seconds. Valid range is [1, 86400].
- !ruby/object:Api::Type::NestedObject
name: 'logConfig'
min_version: beta
description: |
This field denotes the logging options for the load balancer traffic served by this backend service.
If logging is enabled, logs will be exported to Stackdriver.
properties:
- !ruby/object:Api::Type::Boolean
name: 'enable'
description: |
Whether to enable logging for the load balancer traffic served by this backend service.
- !ruby/object:Api::Type::Double
name: 'sampleRate'
description: |
This field can only be specified if logging is enabled for this backend service. The value of
the field must be in [0, 1]. This configures the sampling rate of requests to the load balancer
where 1.0 means all logged requests are reported and 0.0 means no logged requests are reported.
The default value is 1.0.
- !ruby/object:Api::Resource
name: 'RegionBackendService'
kind: 'compute#backendService'
Expand Down
2 changes: 2 additions & 0 deletions products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides
sensitive: true
id: !ruby/object:Overrides::Terraform::PropertyOverride
exclude: true
logConfig: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
portName: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
protocol: !ruby/object:Overrides::Terraform::PropertyOverride
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,39 @@ func TestAccComputeBackendService_internalLoadBalancing(t *testing.T) {
}
<% end -%>

<% unless version == 'ga' -%>
func TestAccComputeBackendService_withLogConfig(t *testing.T) {
t.Parallel()

serviceName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
checkName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeBackendServiceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccComputeBackendService_withLogConfig(serviceName, checkName, 0.7),
},
resource.TestStep{
ResourceName: "google_compute_backend_service.foobar",
ImportState: true,
ImportStateVerify: true,
},
resource.TestStep{
Config: testAccComputeBackendService_withLogConfig(serviceName, checkName, 0.4),
},
resource.TestStep{
ResourceName: "google_compute_backend_service.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
<% end -%>

func testAccComputeBackendService_basic(serviceName, checkName string) string {
return fmt.Sprintf(`
resource "google_compute_backend_service" "foobar" {
Expand Down Expand Up @@ -1449,3 +1482,26 @@ resource "google_compute_instance_template" "foobar" {
}`, fr, proxy, backend, hc, urlmap)
}
<% end -%>

<% unless version == 'ga' -%>
func testAccComputeBackendService_withLogConfig(serviceName, checkName string, sampleRate float64) string {
return fmt.Sprintf(`
resource "google_compute_backend_service" "foobar" {
name = "%s"
health_checks = ["${google_compute_http_health_check.zero.self_link}"]

log_config {
enable = true
sample_rate = %v
}
}

resource "google_compute_http_health_check" "zero" {
name = "%s"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}
`, serviceName, sampleRate, checkName)
}
<% end -%>