From 4e9a95e642b97d05a89931eb7c02627737f0dd8b Mon Sep 17 00:00:00 2001 From: The Magician Date: Fri, 28 Jul 2023 10:53:16 -0700 Subject: [PATCH] Add Terraform support for L3_DEFAULT (all protocol) L4 ILB (#8445) (#5967) * Add Terraform support for L3_DEFAULT (all protocol) L4 ILB * Added test testAccComputeBackendService_withUnspecifiedProtocol * Update mmv1/products/compute/BackendService.yaml * Update mmv1/products/compute/BackendService.yaml --------- Signed-off-by: Modular Magician Co-authored-by: Thomas Rodgers --- .changelog/8445.txt | 4 ++ .../resource_compute_backend_service_test.go | 57 +++++++++++++++++++ .../resource_compute_backend_service.go | 6 +- .../r/compute_backend_service.html.markdown | 6 +- 4 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 .changelog/8445.txt diff --git a/.changelog/8445.txt b/.changelog/8445.txt new file mode 100644 index 0000000000..20df14bb21 --- /dev/null +++ b/.changelog/8445.txt @@ -0,0 +1,4 @@ +```release-note: enhancement +compute: added protocol type: UNSPECIFIED in `google_compute_backend_service` as per [release note](https://cloud.google.com/load-balancing/docs/release-notes#July_24_2023) + +``` diff --git a/google-beta/resource_compute_backend_service_test.go b/google-beta/resource_compute_backend_service_test.go index f440494569..ad118d6cfb 100644 --- a/google-beta/resource_compute_backend_service_test.go +++ b/google-beta/resource_compute_backend_service_test.go @@ -1173,6 +1173,63 @@ resource "google_compute_http_health_check" "default" { `, serviceName, timeout, igName, itName, checkName) } +func testAccComputeBackendService_withUnspecifiedProtocol( + serviceName, igName, itName, checkName string, timeout int64) string { + return fmt.Sprintf(` +data "google_compute_image" "my_image" { + family = "debian-11" + project = "debian-cloud" +} + +resource "google_compute_backend_service" "lipsum" { + name = "%s" + description = "Hello World 1234" + port_name = "http" + protocol = "UNSPECIFIED" + timeout_sec = %v + + backend { + group = google_compute_instance_group_manager.foobar.instance_group + } + + health_checks = [google_compute_http_health_check.default.self_link] +} + +resource "google_compute_instance_group_manager" "foobar" { + name = "%s" + version { + instance_template = google_compute_instance_template.foobar.self_link + name = "primary" + } + base_instance_name = "tf-test-foobar" + zone = "us-central1-f" + target_size = 1 +} + +resource "google_compute_instance_template" "foobar" { + name = "%s" + machine_type = "e2-medium" + + network_interface { + network = "default" + } + + disk { + source_image = data.google_compute_image.my_image.self_link + auto_delete = true + boot = true + } +} + +resource "google_compute_http_health_check" "default" { + name = "%s" + request_path = "/" + check_interval_sec = 1 + timeout_sec = 1 +} +`, serviceName, timeout, igName, itName, checkName) +} + func testAccComputeBackendService_withBackendAndMaxUtilization( serviceName, igName, itName, checkName string, timeout int64) string { return fmt.Sprintf(` diff --git a/google-beta/services/compute/resource_compute_backend_service.go b/google-beta/services/compute/resource_compute_backend_service.go index 0719487a55..51102d7dd0 100644 --- a/google-beta/services/compute/resource_compute_backend_service.go +++ b/google-beta/services/compute/resource_compute_backend_service.go @@ -1037,10 +1037,12 @@ scheme is EXTERNAL.`, Type: schema.TypeString, Computed: true, Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"HTTP", "HTTPS", "HTTP2", "TCP", "SSL", "GRPC", ""}), + ValidateFunc: verify.ValidateEnum([]string{"HTTP", "HTTPS", "HTTP2", "TCP", "SSL", "GRPC", "UNSPECIFIED", ""}), Description: `The protocol this BackendService uses to communicate with backends. The default is HTTP. **NOTE**: HTTP2 is only valid for beta HTTP/2 load balancer -types and may result in errors if used with the GA API. Possible values: ["HTTP", "HTTPS", "HTTP2", "TCP", "SSL", "GRPC"]`, +types and may result in errors if used with the GA API. **NOTE**: With protocol “UNSPECIFIED”, +the backend service can be used by Layer 4 Internal Load Balancing or Network Load Balancing +with TCP/UDP/L3_DEFAULT Forwarding Rule protocol. Possible values: ["HTTP", "HTTPS", "HTTP2", "TCP", "SSL", "GRPC", "UNSPECIFIED"]`, }, "security_policy": { Type: schema.TypeString, diff --git a/website/docs/r/compute_backend_service.html.markdown b/website/docs/r/compute_backend_service.html.markdown index 6112d056d8..e3219310e7 100644 --- a/website/docs/r/compute_backend_service.html.markdown +++ b/website/docs/r/compute_backend_service.html.markdown @@ -515,8 +515,10 @@ The following arguments are supported: (Optional) The protocol this BackendService uses to communicate with backends. The default is HTTP. **NOTE**: HTTP2 is only valid for beta HTTP/2 load balancer - types and may result in errors if used with the GA API. - Possible values are: `HTTP`, `HTTPS`, `HTTP2`, `TCP`, `SSL`, `GRPC`. + types and may result in errors if used with the GA API. **NOTE**: With protocol “UNSPECIFIED”, + the backend service can be used by Layer 4 Internal Load Balancing or Network Load Balancing + with TCP/UDP/L3_DEFAULT Forwarding Rule protocol. + Possible values are: `HTTP`, `HTTPS`, `HTTP2`, `TCP`, `SSL`, `GRPC`, `UNSPECIFIED`. * `security_policy` - (Optional)