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

Move customResponseHeaders to beta only #7943

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
3 changes: 3 additions & 0 deletions .changelog/4286.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
compute: removed `custom_response_headers` from GA `google_compute_backend_service` since it only works in the Beta version
```
37 changes: 0 additions & 37 deletions google/resource_compute_backend_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,16 +466,6 @@ requests.`,
},
Set: schema.HashString,
},
"custom_response_headers": {
Type: schema.TypeSet,
Optional: true,
Description: `Headers that the HTTP/S load balancer should add to proxied
responses.`,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Set: schema.HashString,
},
"description": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -988,12 +978,6 @@ func resourceComputeBackendServiceCreate(d *schema.ResourceData, meta interface{
} else if v, ok := d.GetOkExists("custom_request_headers"); !isEmptyValue(reflect.ValueOf(customRequestHeadersProp)) && (ok || !reflect.DeepEqual(v, customRequestHeadersProp)) {
obj["customRequestHeaders"] = customRequestHeadersProp
}
customResponseHeadersProp, err := expandComputeBackendServiceCustomResponseHeaders(d.Get("custom_response_headers"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("custom_response_headers"); !isEmptyValue(reflect.ValueOf(customResponseHeadersProp)) && (ok || !reflect.DeepEqual(v, customResponseHeadersProp)) {
obj["customResponseHeaders"] = customResponseHeadersProp
}
fingerprintProp, err := expandComputeBackendServiceFingerprint(d.Get("fingerprint"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -1238,9 +1222,6 @@ func resourceComputeBackendServiceRead(d *schema.ResourceData, meta interface{})
if err := d.Set("custom_request_headers", flattenComputeBackendServiceCustomRequestHeaders(res["customRequestHeaders"], d, config)); err != nil {
return fmt.Errorf("Error reading BackendService: %s", err)
}
if err := d.Set("custom_response_headers", flattenComputeBackendServiceCustomResponseHeaders(res["customResponseHeaders"], d, config)); err != nil {
return fmt.Errorf("Error reading BackendService: %s", err)
}
if err := d.Set("fingerprint", flattenComputeBackendServiceFingerprint(res["fingerprint"], d, config)); err != nil {
return fmt.Errorf("Error reading BackendService: %s", err)
}
Expand Down Expand Up @@ -1351,12 +1332,6 @@ func resourceComputeBackendServiceUpdate(d *schema.ResourceData, meta interface{
} else if v, ok := d.GetOkExists("custom_request_headers"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, customRequestHeadersProp)) {
obj["customRequestHeaders"] = customRequestHeadersProp
}
customResponseHeadersProp, err := expandComputeBackendServiceCustomResponseHeaders(d.Get("custom_response_headers"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("custom_response_headers"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, customResponseHeadersProp)) {
obj["customResponseHeaders"] = customResponseHeadersProp
}
fingerprintProp, err := expandComputeBackendServiceFingerprint(d.Get("fingerprint"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -2050,13 +2025,6 @@ func flattenComputeBackendServiceCustomRequestHeaders(v interface{}, d *schema.R
return schema.NewSet(schema.HashString, v.([]interface{}))
}

func flattenComputeBackendServiceCustomResponseHeaders(v interface{}, d *schema.ResourceData, config *Config) interface{} {
if v == nil {
return v
}
return schema.NewSet(schema.HashString, v.([]interface{}))
}

func flattenComputeBackendServiceFingerprint(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}
Expand Down Expand Up @@ -2901,11 +2869,6 @@ func expandComputeBackendServiceCustomRequestHeaders(v interface{}, d TerraformR
return v, nil
}

func expandComputeBackendServiceCustomResponseHeaders(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
v = v.(*schema.Set).List()
return v, nil
}

func expandComputeBackendServiceFingerprint(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
Expand Down
57 changes: 0 additions & 57 deletions google/resource_compute_backend_service_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,63 +118,6 @@ resource "google_compute_http_health_check" "default" {
`, context)
}

func TestAccComputeBackendService_backendServiceNetworkEndpointExample(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": randString(t, 10),
}

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
ExternalProviders: map[string]resource.ExternalProvider{
"random": {},
},
CheckDestroy: testAccCheckComputeBackendServiceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeBackendService_backendServiceNetworkEndpointExample(context),
},
{
ResourceName: "google_compute_backend_service.default",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccComputeBackendService_backendServiceNetworkEndpointExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_compute_global_network_endpoint_group" "external_proxy" {
name = "tf-test-network-endpoint%{random_suffix}"
network_endpoint_type = "INTERNET_FQDN_PORT"
default_port = "443"
}

resource "google_compute_global_network_endpoint" "proxy" {
global_network_endpoint_group = google_compute_global_network_endpoint_group.external_proxy.id
fqdn = "test.example.com"
port = google_compute_global_network_endpoint_group.external_proxy.default_port
}

resource "google_compute_backend_service" "default" {
name = "tf-test-backend-service%{random_suffix}"
enable_cdn = true
timeout_sec = 10
connection_draining_timeout_sec = 10

custom_request_headers = ["host: ${google_compute_global_network_endpoint.proxy.fqdn}"]
custom_response_headers = ["X-Cache-Hit: {cdn_cache_status}"]

backend {
group = google_compute_global_network_endpoint_group.external_proxy.id
}
}
`, context)
}

func testAccCheckComputeBackendServiceDestroyProducer(t *testing.T) func(s *terraform.State) error {
return func(s *terraform.State) error {
for name, rs := range s.RootModule().Resources {
Expand Down
50 changes: 0 additions & 50 deletions google/resource_compute_backend_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,37 +535,6 @@ func TestAccComputeBackendService_withMaxConnectionsPerEndpoint(t *testing.T) {
})
}

func TestAccComputeBackendService_withCustomHeaders(t *testing.T) {
t.Parallel()

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

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeBackendServiceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeBackendService_withCustomHeaders(serviceName, checkName),
},
{
ResourceName: "google_compute_backend_service.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeBackendService_basic(serviceName, checkName),
},
{
ResourceName: "google_compute_backend_service.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccComputeBackendService_internalLoadBalancing(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -1336,25 +1305,6 @@ resource "google_compute_health_check" "default" {
`, service, maxRate, instance, neg, network, network, check)
}

func testAccComputeBackendService_withCustomHeaders(serviceName, checkName string) string {
return fmt.Sprintf(`
resource "google_compute_backend_service" "foobar" {
name = "%s"
health_checks = [google_compute_http_health_check.zero.self_link]

custom_request_headers = ["Client-Region: {client_region}", "Client-Rtt: {client_rtt_msec}"]
custom_response_headers = ["X-Cache-Hit: {cdn_cache_status}", "X-Cache-Id: {cdn_cache_id}"]
}

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

func testAccComputeBackendService_internalLoadBalancing(fr, proxy, backend, hc, urlmap string) string {
return fmt.Sprintf(`
resource "google_compute_global_forwarding_rule" "forwarding_rule" {
Expand Down
5 changes: 4 additions & 1 deletion website/docs/r/compute_backend_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,21 @@ resource "google_compute_health_check" "health_check" {

```hcl
resource "google_compute_global_network_endpoint_group" "external_proxy" {
provider=google-beta
name = "network-endpoint"
network_endpoint_type = "INTERNET_FQDN_PORT"
default_port = "443"
}

resource "google_compute_global_network_endpoint" "proxy" {
provider=google-beta
global_network_endpoint_group = google_compute_global_network_endpoint_group.external_proxy.id
fqdn = "test.example.com"
port = google_compute_global_network_endpoint_group.external_proxy.default_port
}

resource "google_compute_backend_service" "default" {
provider=google-beta
name = "backend-service"
enable_cdn = true
timeout_sec = 10
Expand Down Expand Up @@ -263,7 +266,7 @@ The following arguments are supported:
requests.

* `custom_response_headers` -
(Optional)
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
Headers that the HTTP/S load balancer should add to proxied
responses.

Expand Down