diff --git a/google/resource_compute_health_check.go b/google/resource_compute_health_check.go index c04115fee29..eba430dd1fa 100644 --- a/google/resource_compute_health_check.go +++ b/google/resource_compute_health_check.go @@ -89,6 +89,10 @@ func resourceComputeHealthCheck() *schema.Resource { Optional: true, Default: "/", }, + "response": { + Type: schema.TypeString, + Optional: true, + }, }, }, ConflictsWith: []string{"https_health_check", "tcp_health_check", "ssl_health_check"}, @@ -119,6 +123,10 @@ func resourceComputeHealthCheck() *schema.Resource { Optional: true, Default: "/", }, + "response": { + Type: schema.TypeString, + Optional: true, + }, }, }, ConflictsWith: []string{"http_health_check", "tcp_health_check", "ssl_health_check"}, @@ -610,6 +618,8 @@ func flattenComputeHealthCheckHttpHealthCheck(v interface{}, d *schema.ResourceD flattenComputeHealthCheckHttpHealthCheckHost(original["host"], d) transformed["request_path"] = flattenComputeHealthCheckHttpHealthCheckRequestPath(original["requestPath"], d) + transformed["response"] = + flattenComputeHealthCheckHttpHealthCheckResponse(original["response"], d) transformed["port"] = flattenComputeHealthCheckHttpHealthCheckPort(original["port"], d) transformed["proxy_header"] = @@ -624,6 +634,10 @@ func flattenComputeHealthCheckHttpHealthCheckRequestPath(v interface{}, d *schem return v } +func flattenComputeHealthCheckHttpHealthCheckResponse(v interface{}, d *schema.ResourceData) interface{} { + return v +} + func flattenComputeHealthCheckHttpHealthCheckPort(v interface{}, d *schema.ResourceData) interface{} { // Handles the string fixed64 format if strVal, ok := v.(string); ok { @@ -651,6 +665,8 @@ func flattenComputeHealthCheckHttpsHealthCheck(v interface{}, d *schema.Resource flattenComputeHealthCheckHttpsHealthCheckHost(original["host"], d) transformed["request_path"] = flattenComputeHealthCheckHttpsHealthCheckRequestPath(original["requestPath"], d) + transformed["response"] = + flattenComputeHealthCheckHttpsHealthCheckResponse(original["response"], d) transformed["port"] = flattenComputeHealthCheckHttpsHealthCheckPort(original["port"], d) transformed["proxy_header"] = @@ -665,6 +681,10 @@ func flattenComputeHealthCheckHttpsHealthCheckRequestPath(v interface{}, d *sche return v } +func flattenComputeHealthCheckHttpsHealthCheckResponse(v interface{}, d *schema.ResourceData) interface{} { + return v +} + func flattenComputeHealthCheckHttpsHealthCheckPort(v interface{}, d *schema.ResourceData) interface{} { // Handles the string fixed64 format if strVal, ok := v.(string); ok { @@ -808,6 +828,13 @@ func expandComputeHealthCheckHttpHealthCheck(v interface{}, d *schema.ResourceDa transformed["requestPath"] = transformedRequestPath } + transformedResponse, err := expandComputeHealthCheckHttpHealthCheckResponse(original["response"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedResponse); val.IsValid() && !isEmptyValue(val) { + transformed["response"] = transformedResponse + } + transformedPort, err := expandComputeHealthCheckHttpHealthCheckPort(original["port"], d, config) if err != nil { return nil, err @@ -833,6 +860,10 @@ func expandComputeHealthCheckHttpHealthCheckRequestPath(v interface{}, d *schema return v, nil } +func expandComputeHealthCheckHttpHealthCheckResponse(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) { + return v, nil +} + func expandComputeHealthCheckHttpHealthCheckPort(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) { return v, nil } @@ -864,6 +895,13 @@ func expandComputeHealthCheckHttpsHealthCheck(v interface{}, d *schema.ResourceD transformed["requestPath"] = transformedRequestPath } + transformedResponse, err := expandComputeHealthCheckHttpsHealthCheckResponse(original["response"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedResponse); val.IsValid() && !isEmptyValue(val) { + transformed["response"] = transformedResponse + } + transformedPort, err := expandComputeHealthCheckHttpsHealthCheckPort(original["port"], d, config) if err != nil { return nil, err @@ -889,6 +927,10 @@ func expandComputeHealthCheckHttpsHealthCheckRequestPath(v interface{}, d *schem return v, nil } +func expandComputeHealthCheckHttpsHealthCheckResponse(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) { + return v, nil +} + func expandComputeHealthCheckHttpsHealthCheckPort(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) { return v, nil } diff --git a/website/docs/r/compute_health_check.html.markdown b/website/docs/r/compute_health_check.html.markdown index 7278dc46897..5cc3a5049ec 100644 --- a/website/docs/r/compute_health_check.html.markdown +++ b/website/docs/r/compute_health_check.html.markdown @@ -138,6 +138,12 @@ The `http_health_check` block supports: The request path of the HTTP health check request. The default value is /. +* `response` - + (Optional) + The bytes to match against the beginning of the response data. If left empty + (the default value), any response will indicate health. The response data + can only be ASCII. + * `port` - (Optional) The TCP port number for the HTTP health check request. @@ -161,6 +167,12 @@ The `https_health_check` block supports: The request path of the HTTPS health check request. The default value is /. +* `response` - + (Optional) + The bytes to match against the beginning of the response data. If left empty + (the default value), any response will indicate health. The response data + can only be ASCII. + * `port` - (Optional) The TCP port number for the HTTPS health check request.