| // Copyright (c) HashiCorp, Inc. |
| // SPDX-License-Identifier: MPL-2.0 |
| |
| // ---------------------------------------------------------------------------- |
| // |
| // *** AUTO GENERATED CODE *** Type: MMv1 *** |
| // |
| // ---------------------------------------------------------------------------- |
| // |
| // This file is automatically generated by Magic Modules and manual |
| // changes will be clobbered when the file is regenerated. |
| // |
| // Please read more about how to change this file in |
| // .github/CONTRIBUTING.md. |
| // |
| // ---------------------------------------------------------------------------- |
| |
| package compute |
| |
| import ( |
| "fmt" |
| "log" |
| "reflect" |
| "time" |
| |
| "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" |
| "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" |
| |
| "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" |
| transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" |
| "github.com/hashicorp/terraform-provider-google-beta/google-beta/verify" |
| ) |
| |
| func ResourceComputeRegionHealthCheck() *schema.Resource { |
| return &schema.Resource{ |
| Create: resourceComputeRegionHealthCheckCreate, |
| Read: resourceComputeRegionHealthCheckRead, |
| Update: resourceComputeRegionHealthCheckUpdate, |
| Delete: resourceComputeRegionHealthCheckDelete, |
| |
| Importer: &schema.ResourceImporter{ |
| State: resourceComputeRegionHealthCheckImport, |
| }, |
| |
| Timeouts: &schema.ResourceTimeout{ |
| Create: schema.DefaultTimeout(20 * time.Minute), |
| Update: schema.DefaultTimeout(20 * time.Minute), |
| Delete: schema.DefaultTimeout(20 * time.Minute), |
| }, |
| |
| CustomizeDiff: customdiff.All( |
| healthCheckCustomizeDiff, |
| tpgresource.DefaultProviderProject, |
| ), |
| |
| Schema: map[string]*schema.Schema{ |
| "name": { |
| Type: schema.TypeString, |
| Required: true, |
| ForceNew: true, |
| Description: `Name of the resource. Provided by the client when the resource is |
| created. The name must be 1-63 characters long, and comply with |
| RFC1035. Specifically, the name must be 1-63 characters long and |
| match the regular expression '[a-z]([-a-z0-9]*[a-z0-9])?' which means |
| the first character must be a lowercase letter, and all following |
| characters must be a dash, lowercase letter, or digit, except the |
| last character, which cannot be a dash.`, |
| }, |
| "check_interval_sec": { |
| Type: schema.TypeInt, |
| Optional: true, |
| Description: `How often (in seconds) to send a health check. The default value is 5 |
| seconds.`, |
| Default: 5, |
| }, |
| "description": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `An optional description of this resource. Provide this property when |
| you create the resource.`, |
| }, |
| "grpc_health_check": { |
| Type: schema.TypeList, |
| Optional: true, |
| DiffSuppressFunc: portDiffSuppress, |
| Description: `A nested object resource`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "grpc_service_name": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `The gRPC service name for the health check. |
| The value of grpcServiceName has the following meanings by convention: |
| |
| * Empty serviceName means the overall status of all services at the backend. |
| * Non-empty serviceName means the health of that gRPC service, as defined by the owner of the service. |
| |
| The grpcServiceName can only be ASCII.`, |
| AtLeastOneOf: []string{"grpc_health_check.0.port", "grpc_health_check.0.port_name", "grpc_health_check.0.port_specification", "grpc_health_check.0.grpc_service_name"}, |
| }, |
| "port": { |
| Type: schema.TypeInt, |
| Optional: true, |
| Description: `The port number for the health check request. |
| Must be specified if portName and portSpecification are not set |
| or if port_specification is USE_FIXED_PORT. Valid values are 1 through 65535.`, |
| AtLeastOneOf: []string{"grpc_health_check.0.port", "grpc_health_check.0.port_name", "grpc_health_check.0.port_specification", "grpc_health_check.0.grpc_service_name"}, |
| }, |
| "port_name": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `Port name as defined in InstanceGroup#NamedPort#name. If both port and |
| port_name are defined, port takes precedence.`, |
| AtLeastOneOf: []string{"grpc_health_check.0.port", "grpc_health_check.0.port_name", "grpc_health_check.0.port_specification", "grpc_health_check.0.grpc_service_name"}, |
| }, |
| "port_specification": { |
| Type: schema.TypeString, |
| Optional: true, |
| ValidateFunc: verify.ValidateEnum([]string{"USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT", ""}), |
| Description: `Specifies how port is selected for health checking, can be one of the |
| following values: |
| |
| * 'USE_FIXED_PORT': The port number in 'port' is used for health checking. |
| |
| * 'USE_NAMED_PORT': The 'portName' is used for health checking. |
| |
| * 'USE_SERVING_PORT': For NetworkEndpointGroup, the port specified for each |
| network endpoint is used for health checking. For other backends, the |
| port or named port specified in the Backend Service is used for health |
| checking. |
| |
| If not specified, gRPC health check follows behavior specified in 'port' and |
| 'portName' fields. Possible values: ["USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT"]`, |
| AtLeastOneOf: []string{"grpc_health_check.0.port", "grpc_health_check.0.port_name", "grpc_health_check.0.port_specification", "grpc_health_check.0.grpc_service_name"}, |
| }, |
| }, |
| }, |
| ExactlyOneOf: []string{"http_health_check", "https_health_check", "http2_health_check", "tcp_health_check", "ssl_health_check", "grpc_health_check"}, |
| }, |
| "healthy_threshold": { |
| Type: schema.TypeInt, |
| Optional: true, |
| Description: `A so-far unhealthy instance will be marked healthy after this many |
| consecutive successes. The default value is 2.`, |
| Default: 2, |
| }, |
| "http2_health_check": { |
| Type: schema.TypeList, |
| Optional: true, |
| DiffSuppressFunc: portDiffSuppress, |
| Description: `A nested object resource`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "host": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `The value of the host header in the HTTP2 health check request. |
| If left empty (default value), the public IP on behalf of which this health |
| check is performed will be used.`, |
| AtLeastOneOf: []string{"http2_health_check.0.host", "http2_health_check.0.request_path", "http2_health_check.0.response", "http2_health_check.0.port", "http2_health_check.0.port_name", "http2_health_check.0.proxy_header", "http2_health_check.0.port_specification"}, |
| }, |
| "port": { |
| Type: schema.TypeInt, |
| Optional: true, |
| Description: `The TCP port number for the HTTP2 health check request. |
| The default value is 443.`, |
| AtLeastOneOf: []string{"http2_health_check.0.host", "http2_health_check.0.request_path", "http2_health_check.0.response", "http2_health_check.0.port", "http2_health_check.0.port_name", "http2_health_check.0.proxy_header", "http2_health_check.0.port_specification"}, |
| }, |
| "port_name": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `Port name as defined in InstanceGroup#NamedPort#name. If both port and |
| port_name are defined, port takes precedence.`, |
| AtLeastOneOf: []string{"http2_health_check.0.host", "http2_health_check.0.request_path", "http2_health_check.0.response", "http2_health_check.0.port", "http2_health_check.0.port_name", "http2_health_check.0.proxy_header", "http2_health_check.0.port_specification"}, |
| }, |
| "port_specification": { |
| Type: schema.TypeString, |
| Optional: true, |
| ValidateFunc: verify.ValidateEnum([]string{"USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT", ""}), |
| Description: `Specifies how port is selected for health checking, can be one of the |
| following values: |
| |
| * 'USE_FIXED_PORT': The port number in 'port' is used for health checking. |
| |
| * 'USE_NAMED_PORT': The 'portName' is used for health checking. |
| |
| * 'USE_SERVING_PORT': For NetworkEndpointGroup, the port specified for each |
| network endpoint is used for health checking. For other backends, the |
| port or named port specified in the Backend Service is used for health |
| checking. |
| |
| If not specified, HTTP2 health check follows behavior specified in 'port' and |
| 'portName' fields. Possible values: ["USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT"]`, |
| AtLeastOneOf: []string{"http2_health_check.0.host", "http2_health_check.0.request_path", "http2_health_check.0.response", "http2_health_check.0.port", "http2_health_check.0.port_name", "http2_health_check.0.proxy_header", "http2_health_check.0.port_specification"}, |
| }, |
| "proxy_header": { |
| Type: schema.TypeString, |
| Optional: true, |
| ValidateFunc: verify.ValidateEnum([]string{"NONE", "PROXY_V1", ""}), |
| Description: `Specifies the type of proxy header to append before sending data to the |
| backend. Default value: "NONE" Possible values: ["NONE", "PROXY_V1"]`, |
| Default: "NONE", |
| AtLeastOneOf: []string{"http2_health_check.0.host", "http2_health_check.0.request_path", "http2_health_check.0.response", "http2_health_check.0.port", "http2_health_check.0.port_name", "http2_health_check.0.proxy_header", "http2_health_check.0.port_specification"}, |
| }, |
| "request_path": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `The request path of the HTTP2 health check request. |
| The default value is /.`, |
| Default: "/", |
| AtLeastOneOf: []string{"http2_health_check.0.host", "http2_health_check.0.request_path", "http2_health_check.0.response", "http2_health_check.0.port", "http2_health_check.0.port_name", "http2_health_check.0.proxy_header", "http2_health_check.0.port_specification"}, |
| }, |
| "response": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `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.`, |
| AtLeastOneOf: []string{"http2_health_check.0.host", "http2_health_check.0.request_path", "http2_health_check.0.response", "http2_health_check.0.port", "http2_health_check.0.port_name", "http2_health_check.0.proxy_header", "http2_health_check.0.port_specification"}, |
| }, |
| }, |
| }, |
| ExactlyOneOf: []string{"http_health_check", "https_health_check", "http2_health_check", "tcp_health_check", "ssl_health_check", "grpc_health_check"}, |
| }, |
| "http_health_check": { |
| Type: schema.TypeList, |
| Optional: true, |
| DiffSuppressFunc: portDiffSuppress, |
| Description: `A nested object resource`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "host": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `The value of the host header in the HTTP health check request. |
| If left empty (default value), the public IP on behalf of which this health |
| check is performed will be used.`, |
| AtLeastOneOf: []string{"http_health_check.0.host", "http_health_check.0.request_path", "http_health_check.0.response", "http_health_check.0.port", "http_health_check.0.port_name", "http_health_check.0.proxy_header", "http_health_check.0.port_specification"}, |
| }, |
| "port": { |
| Type: schema.TypeInt, |
| Optional: true, |
| Description: `The TCP port number for the HTTP health check request. |
| The default value is 80.`, |
| AtLeastOneOf: []string{"http_health_check.0.host", "http_health_check.0.request_path", "http_health_check.0.response", "http_health_check.0.port", "http_health_check.0.port_name", "http_health_check.0.proxy_header", "http_health_check.0.port_specification"}, |
| }, |
| "port_name": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `Port name as defined in InstanceGroup#NamedPort#name. If both port and |
| port_name are defined, port takes precedence.`, |
| AtLeastOneOf: []string{"http_health_check.0.host", "http_health_check.0.request_path", "http_health_check.0.response", "http_health_check.0.port", "http_health_check.0.port_name", "http_health_check.0.proxy_header", "http_health_check.0.port_specification"}, |
| }, |
| "port_specification": { |
| Type: schema.TypeString, |
| Optional: true, |
| ValidateFunc: verify.ValidateEnum([]string{"USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT", ""}), |
| Description: `Specifies how port is selected for health checking, can be one of the |
| following values: |
| |
| * 'USE_FIXED_PORT': The port number in 'port' is used for health checking. |
| |
| * 'USE_NAMED_PORT': The 'portName' is used for health checking. |
| |
| * 'USE_SERVING_PORT': For NetworkEndpointGroup, the port specified for each |
| network endpoint is used for health checking. For other backends, the |
| port or named port specified in the Backend Service is used for health |
| checking. |
| |
| If not specified, HTTP health check follows behavior specified in 'port' and |
| 'portName' fields. Possible values: ["USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT"]`, |
| AtLeastOneOf: []string{"http_health_check.0.host", "http_health_check.0.request_path", "http_health_check.0.response", "http_health_check.0.port", "http_health_check.0.port_name", "http_health_check.0.proxy_header", "http_health_check.0.port_specification"}, |
| }, |
| "proxy_header": { |
| Type: schema.TypeString, |
| Optional: true, |
| ValidateFunc: verify.ValidateEnum([]string{"NONE", "PROXY_V1", ""}), |
| Description: `Specifies the type of proxy header to append before sending data to the |
| backend. Default value: "NONE" Possible values: ["NONE", "PROXY_V1"]`, |
| Default: "NONE", |
| AtLeastOneOf: []string{"http_health_check.0.host", "http_health_check.0.request_path", "http_health_check.0.response", "http_health_check.0.port", "http_health_check.0.port_name", "http_health_check.0.proxy_header", "http_health_check.0.port_specification"}, |
| }, |
| "request_path": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `The request path of the HTTP health check request. |
| The default value is /.`, |
| Default: "/", |
| AtLeastOneOf: []string{"http_health_check.0.host", "http_health_check.0.request_path", "http_health_check.0.response", "http_health_check.0.port", "http_health_check.0.port_name", "http_health_check.0.proxy_header", "http_health_check.0.port_specification"}, |
| }, |
| "response": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `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.`, |
| AtLeastOneOf: []string{"http_health_check.0.host", "http_health_check.0.request_path", "http_health_check.0.response", "http_health_check.0.port", "http_health_check.0.port_name", "http_health_check.0.proxy_header", "http_health_check.0.port_specification"}, |
| }, |
| }, |
| }, |
| ExactlyOneOf: []string{"http_health_check", "https_health_check", "http2_health_check", "tcp_health_check", "ssl_health_check", "grpc_health_check"}, |
| }, |
| "https_health_check": { |
| Type: schema.TypeList, |
| Optional: true, |
| DiffSuppressFunc: portDiffSuppress, |
| Description: `A nested object resource`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "host": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `The value of the host header in the HTTPS health check request. |
| If left empty (default value), the public IP on behalf of which this health |
| check is performed will be used.`, |
| AtLeastOneOf: []string{"https_health_check.0.host", "https_health_check.0.request_path", "https_health_check.0.response", "https_health_check.0.port", "https_health_check.0.port_name", "https_health_check.0.proxy_header", "https_health_check.0.port_specification"}, |
| }, |
| "port": { |
| Type: schema.TypeInt, |
| Optional: true, |
| Description: `The TCP port number for the HTTPS health check request. |
| The default value is 443.`, |
| AtLeastOneOf: []string{"https_health_check.0.host", "https_health_check.0.request_path", "https_health_check.0.response", "https_health_check.0.port", "https_health_check.0.port_name", "https_health_check.0.proxy_header", "https_health_check.0.port_specification"}, |
| }, |
| "port_name": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `Port name as defined in InstanceGroup#NamedPort#name. If both port and |
| port_name are defined, port takes precedence.`, |
| AtLeastOneOf: []string{"https_health_check.0.host", "https_health_check.0.request_path", "https_health_check.0.response", "https_health_check.0.port", "https_health_check.0.port_name", "https_health_check.0.proxy_header", "https_health_check.0.port_specification"}, |
| }, |
| "port_specification": { |
| Type: schema.TypeString, |
| Optional: true, |
| ValidateFunc: verify.ValidateEnum([]string{"USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT", ""}), |
| Description: `Specifies how port is selected for health checking, can be one of the |
| following values: |
| |
| * 'USE_FIXED_PORT': The port number in 'port' is used for health checking. |
| |
| * 'USE_NAMED_PORT': The 'portName' is used for health checking. |
| |
| * 'USE_SERVING_PORT': For NetworkEndpointGroup, the port specified for each |
| network endpoint is used for health checking. For other backends, the |
| port or named port specified in the Backend Service is used for health |
| checking. |
| |
| If not specified, HTTPS health check follows behavior specified in 'port' and |
| 'portName' fields. Possible values: ["USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT"]`, |
| AtLeastOneOf: []string{"https_health_check.0.host", "https_health_check.0.request_path", "https_health_check.0.response", "https_health_check.0.port", "https_health_check.0.port_name", "https_health_check.0.proxy_header", "https_health_check.0.port_specification"}, |
| }, |
| "proxy_header": { |
| Type: schema.TypeString, |
| Optional: true, |
| ValidateFunc: verify.ValidateEnum([]string{"NONE", "PROXY_V1", ""}), |
| Description: `Specifies the type of proxy header to append before sending data to the |
| backend. Default value: "NONE" Possible values: ["NONE", "PROXY_V1"]`, |
| Default: "NONE", |
| AtLeastOneOf: []string{"https_health_check.0.host", "https_health_check.0.request_path", "https_health_check.0.response", "https_health_check.0.port", "https_health_check.0.port_name", "https_health_check.0.proxy_header", "https_health_check.0.port_specification"}, |
| }, |
| "request_path": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `The request path of the HTTPS health check request. |
| The default value is /.`, |
| Default: "/", |
| AtLeastOneOf: []string{"https_health_check.0.host", "https_health_check.0.request_path", "https_health_check.0.response", "https_health_check.0.port", "https_health_check.0.port_name", "https_health_check.0.proxy_header", "https_health_check.0.port_specification"}, |
| }, |
| "response": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `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.`, |
| AtLeastOneOf: []string{"https_health_check.0.host", "https_health_check.0.request_path", "https_health_check.0.response", "https_health_check.0.port", "https_health_check.0.port_name", "https_health_check.0.proxy_header", "https_health_check.0.port_specification"}, |
| }, |
| }, |
| }, |
| ExactlyOneOf: []string{"http_health_check", "https_health_check", "http2_health_check", "tcp_health_check", "ssl_health_check", "grpc_health_check"}, |
| }, |
| "log_config": { |
| Type: schema.TypeList, |
| Computed: true, |
| Optional: true, |
| Description: `Configure logging on this health check.`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "enable": { |
| Type: schema.TypeBool, |
| Optional: true, |
| Description: `Indicates whether or not to export logs. This is false by default, |
| which means no health check logging will be done.`, |
| Default: false, |
| }, |
| }, |
| }, |
| }, |
| "region": { |
| Type: schema.TypeString, |
| Computed: true, |
| Optional: true, |
| ForceNew: true, |
| DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, |
| Description: `The Region in which the created health check should reside. |
| If it is not provided, the provider region is used.`, |
| }, |
| "ssl_health_check": { |
| Type: schema.TypeList, |
| Optional: true, |
| DiffSuppressFunc: portDiffSuppress, |
| Description: `A nested object resource`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "port": { |
| Type: schema.TypeInt, |
| Optional: true, |
| Description: `The TCP port number for the SSL health check request. |
| The default value is 443.`, |
| AtLeastOneOf: []string{"ssl_health_check.0.request", "ssl_health_check.0.response", "ssl_health_check.0.port", "ssl_health_check.0.port_name", "ssl_health_check.0.proxy_header", "ssl_health_check.0.port_specification"}, |
| }, |
| "port_name": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `Port name as defined in InstanceGroup#NamedPort#name. If both port and |
| port_name are defined, port takes precedence.`, |
| AtLeastOneOf: []string{"ssl_health_check.0.request", "ssl_health_check.0.response", "ssl_health_check.0.port", "ssl_health_check.0.port_name", "ssl_health_check.0.proxy_header", "ssl_health_check.0.port_specification"}, |
| }, |
| "port_specification": { |
| Type: schema.TypeString, |
| Optional: true, |
| ValidateFunc: verify.ValidateEnum([]string{"USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT", ""}), |
| Description: `Specifies how port is selected for health checking, can be one of the |
| following values: |
| |
| * 'USE_FIXED_PORT': The port number in 'port' is used for health checking. |
| |
| * 'USE_NAMED_PORT': The 'portName' is used for health checking. |
| |
| * 'USE_SERVING_PORT': For NetworkEndpointGroup, the port specified for each |
| network endpoint is used for health checking. For other backends, the |
| port or named port specified in the Backend Service is used for health |
| checking. |
| |
| If not specified, SSL health check follows behavior specified in 'port' and |
| 'portName' fields. Possible values: ["USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT"]`, |
| AtLeastOneOf: []string{"ssl_health_check.0.request", "ssl_health_check.0.response", "ssl_health_check.0.port", "ssl_health_check.0.port_name", "ssl_health_check.0.proxy_header", "ssl_health_check.0.port_specification"}, |
| }, |
| "proxy_header": { |
| Type: schema.TypeString, |
| Optional: true, |
| ValidateFunc: verify.ValidateEnum([]string{"NONE", "PROXY_V1", ""}), |
| Description: `Specifies the type of proxy header to append before sending data to the |
| backend. Default value: "NONE" Possible values: ["NONE", "PROXY_V1"]`, |
| Default: "NONE", |
| AtLeastOneOf: []string{"ssl_health_check.0.request", "ssl_health_check.0.response", "ssl_health_check.0.port", "ssl_health_check.0.port_name", "ssl_health_check.0.proxy_header", "ssl_health_check.0.port_specification"}, |
| }, |
| "request": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `The application data to send once the SSL connection has been |
| established (default value is empty). If both request and response are |
| empty, the connection establishment alone will indicate health. The request |
| data can only be ASCII.`, |
| AtLeastOneOf: []string{"ssl_health_check.0.request", "ssl_health_check.0.response", "ssl_health_check.0.port", "ssl_health_check.0.port_name", "ssl_health_check.0.proxy_header", "ssl_health_check.0.port_specification"}, |
| }, |
| "response": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `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.`, |
| AtLeastOneOf: []string{"ssl_health_check.0.request", "ssl_health_check.0.response", "ssl_health_check.0.port", "ssl_health_check.0.port_name", "ssl_health_check.0.proxy_header", "ssl_health_check.0.port_specification"}, |
| }, |
| }, |
| }, |
| ExactlyOneOf: []string{"http_health_check", "https_health_check", "http2_health_check", "tcp_health_check", "ssl_health_check", "grpc_health_check"}, |
| }, |
| "tcp_health_check": { |
| Type: schema.TypeList, |
| Optional: true, |
| DiffSuppressFunc: portDiffSuppress, |
| Description: `A nested object resource`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "port": { |
| Type: schema.TypeInt, |
| Optional: true, |
| Description: `The TCP port number for the TCP health check request. |
| The default value is 80.`, |
| AtLeastOneOf: []string{"tcp_health_check.0.request", "tcp_health_check.0.response", "tcp_health_check.0.port", "tcp_health_check.0.port_name", "tcp_health_check.0.proxy_header", "tcp_health_check.0.port_specification"}, |
| }, |
| "port_name": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `Port name as defined in InstanceGroup#NamedPort#name. If both port and |
| port_name are defined, port takes precedence.`, |
| AtLeastOneOf: []string{"tcp_health_check.0.request", "tcp_health_check.0.response", "tcp_health_check.0.port", "tcp_health_check.0.port_name", "tcp_health_check.0.proxy_header", "tcp_health_check.0.port_specification"}, |
| }, |
| "port_specification": { |
| Type: schema.TypeString, |
| Optional: true, |
| ValidateFunc: verify.ValidateEnum([]string{"USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT", ""}), |
| Description: `Specifies how port is selected for health checking, can be one of the |
| following values: |
| |
| * 'USE_FIXED_PORT': The port number in 'port' is used for health checking. |
| |
| * 'USE_NAMED_PORT': The 'portName' is used for health checking. |
| |
| * 'USE_SERVING_PORT': For NetworkEndpointGroup, the port specified for each |
| network endpoint is used for health checking. For other backends, the |
| port or named port specified in the Backend Service is used for health |
| checking. |
| |
| If not specified, TCP health check follows behavior specified in 'port' and |
| 'portName' fields. Possible values: ["USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT"]`, |
| AtLeastOneOf: []string{"tcp_health_check.0.request", "tcp_health_check.0.response", "tcp_health_check.0.port", "tcp_health_check.0.port_name", "tcp_health_check.0.proxy_header", "tcp_health_check.0.port_specification"}, |
| }, |
| "proxy_header": { |
| Type: schema.TypeString, |
| Optional: true, |
| ValidateFunc: verify.ValidateEnum([]string{"NONE", "PROXY_V1", ""}), |
| Description: `Specifies the type of proxy header to append before sending data to the |
| backend. Default value: "NONE" Possible values: ["NONE", "PROXY_V1"]`, |
| Default: "NONE", |
| AtLeastOneOf: []string{"tcp_health_check.0.request", "tcp_health_check.0.response", "tcp_health_check.0.port", "tcp_health_check.0.port_name", "tcp_health_check.0.proxy_header", "tcp_health_check.0.port_specification"}, |
| }, |
| "request": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `The application data to send once the TCP connection has been |
| established (default value is empty). If both request and response are |
| empty, the connection establishment alone will indicate health. The request |
| data can only be ASCII.`, |
| AtLeastOneOf: []string{"tcp_health_check.0.request", "tcp_health_check.0.response", "tcp_health_check.0.port", "tcp_health_check.0.port_name", "tcp_health_check.0.proxy_header", "tcp_health_check.0.port_specification"}, |
| }, |
| "response": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `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.`, |
| AtLeastOneOf: []string{"tcp_health_check.0.request", "tcp_health_check.0.response", "tcp_health_check.0.port", "tcp_health_check.0.port_name", "tcp_health_check.0.proxy_header", "tcp_health_check.0.port_specification"}, |
| }, |
| }, |
| }, |
| ExactlyOneOf: []string{"http_health_check", "https_health_check", "http2_health_check", "tcp_health_check", "ssl_health_check", "grpc_health_check"}, |
| }, |
| "timeout_sec": { |
| Type: schema.TypeInt, |
| Optional: true, |
| Description: `How long (in seconds) to wait before claiming failure. |
| The default value is 5 seconds. It is invalid for timeoutSec to have |
| greater value than checkIntervalSec.`, |
| Default: 5, |
| }, |
| "unhealthy_threshold": { |
| Type: schema.TypeInt, |
| Optional: true, |
| Description: `A so-far healthy instance will be marked unhealthy after this many |
| consecutive failures. The default value is 2.`, |
| Default: 2, |
| }, |
| "creation_timestamp": { |
| Type: schema.TypeString, |
| Computed: true, |
| Description: `Creation timestamp in RFC3339 text format.`, |
| }, |
| "type": { |
| Type: schema.TypeString, |
| Computed: true, |
| Description: `The type of the health check. One of HTTP, HTTP2, HTTPS, TCP, or SSL.`, |
| }, |
| "project": { |
| Type: schema.TypeString, |
| Optional: true, |
| Computed: true, |
| ForceNew: true, |
| }, |
| "self_link": { |
| Type: schema.TypeString, |
| Computed: true, |
| }, |
| }, |
| UseJSONNumber: true, |
| } |
| } |
| |
| func resourceComputeRegionHealthCheckCreate(d *schema.ResourceData, meta interface{}) error { |
| config := meta.(*transport_tpg.Config) |
| userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) |
| if err != nil { |
| return err |
| } |
| |
| obj := make(map[string]interface{}) |
| checkIntervalSecProp, err := expandComputeRegionHealthCheckCheckIntervalSec(d.Get("check_interval_sec"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("check_interval_sec"); !tpgresource.IsEmptyValue(reflect.ValueOf(checkIntervalSecProp)) && (ok || !reflect.DeepEqual(v, checkIntervalSecProp)) { |
| obj["checkIntervalSec"] = checkIntervalSecProp |
| } |
| descriptionProp, err := expandComputeRegionHealthCheckDescription(d.Get("description"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("description"); ok || !reflect.DeepEqual(v, descriptionProp) { |
| obj["description"] = descriptionProp |
| } |
| healthyThresholdProp, err := expandComputeRegionHealthCheckHealthyThreshold(d.Get("healthy_threshold"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("healthy_threshold"); !tpgresource.IsEmptyValue(reflect.ValueOf(healthyThresholdProp)) && (ok || !reflect.DeepEqual(v, healthyThresholdProp)) { |
| obj["healthyThreshold"] = healthyThresholdProp |
| } |
| nameProp, err := expandComputeRegionHealthCheckName(d.Get("name"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) { |
| obj["name"] = nameProp |
| } |
| unhealthyThresholdProp, err := expandComputeRegionHealthCheckUnhealthyThreshold(d.Get("unhealthy_threshold"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("unhealthy_threshold"); !tpgresource.IsEmptyValue(reflect.ValueOf(unhealthyThresholdProp)) && (ok || !reflect.DeepEqual(v, unhealthyThresholdProp)) { |
| obj["unhealthyThreshold"] = unhealthyThresholdProp |
| } |
| timeoutSecProp, err := expandComputeRegionHealthCheckTimeoutSec(d.Get("timeout_sec"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("timeout_sec"); !tpgresource.IsEmptyValue(reflect.ValueOf(timeoutSecProp)) && (ok || !reflect.DeepEqual(v, timeoutSecProp)) { |
| obj["timeoutSec"] = timeoutSecProp |
| } |
| httpHealthCheckProp, err := expandComputeRegionHealthCheckHttpHealthCheck(d.Get("http_health_check"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("http_health_check"); !tpgresource.IsEmptyValue(reflect.ValueOf(httpHealthCheckProp)) && (ok || !reflect.DeepEqual(v, httpHealthCheckProp)) { |
| obj["httpHealthCheck"] = httpHealthCheckProp |
| } |
| httpsHealthCheckProp, err := expandComputeRegionHealthCheckHttpsHealthCheck(d.Get("https_health_check"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("https_health_check"); !tpgresource.IsEmptyValue(reflect.ValueOf(httpsHealthCheckProp)) && (ok || !reflect.DeepEqual(v, httpsHealthCheckProp)) { |
| obj["httpsHealthCheck"] = httpsHealthCheckProp |
| } |
| tcpHealthCheckProp, err := expandComputeRegionHealthCheckTcpHealthCheck(d.Get("tcp_health_check"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("tcp_health_check"); !tpgresource.IsEmptyValue(reflect.ValueOf(tcpHealthCheckProp)) && (ok || !reflect.DeepEqual(v, tcpHealthCheckProp)) { |
| obj["tcpHealthCheck"] = tcpHealthCheckProp |
| } |
| sslHealthCheckProp, err := expandComputeRegionHealthCheckSslHealthCheck(d.Get("ssl_health_check"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("ssl_health_check"); !tpgresource.IsEmptyValue(reflect.ValueOf(sslHealthCheckProp)) && (ok || !reflect.DeepEqual(v, sslHealthCheckProp)) { |
| obj["sslHealthCheck"] = sslHealthCheckProp |
| } |
| http2HealthCheckProp, err := expandComputeRegionHealthCheckHttp2HealthCheck(d.Get("http2_health_check"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("http2_health_check"); !tpgresource.IsEmptyValue(reflect.ValueOf(http2HealthCheckProp)) && (ok || !reflect.DeepEqual(v, http2HealthCheckProp)) { |
| obj["http2HealthCheck"] = http2HealthCheckProp |
| } |
| grpcHealthCheckProp, err := expandComputeRegionHealthCheckGrpcHealthCheck(d.Get("grpc_health_check"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("grpc_health_check"); !tpgresource.IsEmptyValue(reflect.ValueOf(grpcHealthCheckProp)) && (ok || !reflect.DeepEqual(v, grpcHealthCheckProp)) { |
| obj["grpcHealthCheck"] = grpcHealthCheckProp |
| } |
| logConfigProp, err := expandComputeRegionHealthCheckLogConfig(d.Get("log_config"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("log_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(logConfigProp)) && (ok || !reflect.DeepEqual(v, logConfigProp)) { |
| obj["logConfig"] = logConfigProp |
| } |
| regionProp, err := expandComputeRegionHealthCheckRegion(d.Get("region"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("region"); !tpgresource.IsEmptyValue(reflect.ValueOf(regionProp)) && (ok || !reflect.DeepEqual(v, regionProp)) { |
| obj["region"] = regionProp |
| } |
| |
| obj, err = resourceComputeRegionHealthCheckEncoder(d, meta, obj) |
| if err != nil { |
| return err |
| } |
| |
| url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/healthChecks") |
| if err != nil { |
| return err |
| } |
| |
| log.Printf("[DEBUG] Creating new RegionHealthCheck: %#v", obj) |
| billingProject := "" |
| |
| project, err := tpgresource.GetProject(d, config) |
| if err != nil { |
| return fmt.Errorf("Error fetching project for RegionHealthCheck: %s", err) |
| } |
| billingProject = project |
| |
| // err == nil indicates that the billing_project value was found |
| if bp, err := tpgresource.GetBillingProject(d, config); err == nil { |
| billingProject = bp |
| } |
| |
| res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ |
| Config: config, |
| Method: "POST", |
| Project: billingProject, |
| RawURL: url, |
| UserAgent: userAgent, |
| Body: obj, |
| Timeout: d.Timeout(schema.TimeoutCreate), |
| }) |
| if err != nil { |
| return fmt.Errorf("Error creating RegionHealthCheck: %s", err) |
| } |
| |
| // Store the ID now |
| id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/regions/{{region}}/healthChecks/{{name}}") |
| if err != nil { |
| return fmt.Errorf("Error constructing id: %s", err) |
| } |
| d.SetId(id) |
| |
| err = ComputeOperationWaitTime( |
| config, res, project, "Creating RegionHealthCheck", userAgent, |
| d.Timeout(schema.TimeoutCreate)) |
| |
| if err != nil { |
| // The resource didn't actually create |
| d.SetId("") |
| return fmt.Errorf("Error waiting to create RegionHealthCheck: %s", err) |
| } |
| |
| log.Printf("[DEBUG] Finished creating RegionHealthCheck %q: %#v", d.Id(), res) |
| |
| return resourceComputeRegionHealthCheckRead(d, meta) |
| } |
| |
| func resourceComputeRegionHealthCheckRead(d *schema.ResourceData, meta interface{}) error { |
| config := meta.(*transport_tpg.Config) |
| userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) |
| if err != nil { |
| return err |
| } |
| |
| url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/healthChecks/{{name}}") |
| if err != nil { |
| return err |
| } |
| |
| billingProject := "" |
| |
| project, err := tpgresource.GetProject(d, config) |
| if err != nil { |
| return fmt.Errorf("Error fetching project for RegionHealthCheck: %s", err) |
| } |
| billingProject = project |
| |
| // err == nil indicates that the billing_project value was found |
| if bp, err := tpgresource.GetBillingProject(d, config); err == nil { |
| billingProject = bp |
| } |
| |
| res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ |
| Config: config, |
| Method: "GET", |
| Project: billingProject, |
| RawURL: url, |
| UserAgent: userAgent, |
| }) |
| if err != nil { |
| return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionHealthCheck %q", d.Id())) |
| } |
| |
| if err := d.Set("project", project); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| |
| if err := d.Set("check_interval_sec", flattenComputeRegionHealthCheckCheckIntervalSec(res["checkIntervalSec"], d, config)); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| if err := d.Set("creation_timestamp", flattenComputeRegionHealthCheckCreationTimestamp(res["creationTimestamp"], d, config)); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| if err := d.Set("description", flattenComputeRegionHealthCheckDescription(res["description"], d, config)); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| if err := d.Set("healthy_threshold", flattenComputeRegionHealthCheckHealthyThreshold(res["healthyThreshold"], d, config)); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| if err := d.Set("name", flattenComputeRegionHealthCheckName(res["name"], d, config)); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| if err := d.Set("unhealthy_threshold", flattenComputeRegionHealthCheckUnhealthyThreshold(res["unhealthyThreshold"], d, config)); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| if err := d.Set("timeout_sec", flattenComputeRegionHealthCheckTimeoutSec(res["timeoutSec"], d, config)); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| if err := d.Set("type", flattenComputeRegionHealthCheckType(res["type"], d, config)); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| if err := d.Set("http_health_check", flattenComputeRegionHealthCheckHttpHealthCheck(res["httpHealthCheck"], d, config)); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| if err := d.Set("https_health_check", flattenComputeRegionHealthCheckHttpsHealthCheck(res["httpsHealthCheck"], d, config)); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| if err := d.Set("tcp_health_check", flattenComputeRegionHealthCheckTcpHealthCheck(res["tcpHealthCheck"], d, config)); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| if err := d.Set("ssl_health_check", flattenComputeRegionHealthCheckSslHealthCheck(res["sslHealthCheck"], d, config)); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| if err := d.Set("http2_health_check", flattenComputeRegionHealthCheckHttp2HealthCheck(res["http2HealthCheck"], d, config)); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| if err := d.Set("grpc_health_check", flattenComputeRegionHealthCheckGrpcHealthCheck(res["grpcHealthCheck"], d, config)); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| if err := d.Set("log_config", flattenComputeRegionHealthCheckLogConfig(res["logConfig"], d, config)); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| if err := d.Set("region", flattenComputeRegionHealthCheckRegion(res["region"], d, config)); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| if err := d.Set("self_link", tpgresource.ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil { |
| return fmt.Errorf("Error reading RegionHealthCheck: %s", err) |
| } |
| |
| return nil |
| } |
| |
| func resourceComputeRegionHealthCheckUpdate(d *schema.ResourceData, meta interface{}) error { |
| config := meta.(*transport_tpg.Config) |
| userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) |
| if err != nil { |
| return err |
| } |
| |
| billingProject := "" |
| |
| project, err := tpgresource.GetProject(d, config) |
| if err != nil { |
| return fmt.Errorf("Error fetching project for RegionHealthCheck: %s", err) |
| } |
| billingProject = project |
| |
| obj := make(map[string]interface{}) |
| checkIntervalSecProp, err := expandComputeRegionHealthCheckCheckIntervalSec(d.Get("check_interval_sec"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("check_interval_sec"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, checkIntervalSecProp)) { |
| obj["checkIntervalSec"] = checkIntervalSecProp |
| } |
| descriptionProp, err := expandComputeRegionHealthCheckDescription(d.Get("description"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("description"); ok || !reflect.DeepEqual(v, descriptionProp) { |
| obj["description"] = descriptionProp |
| } |
| healthyThresholdProp, err := expandComputeRegionHealthCheckHealthyThreshold(d.Get("healthy_threshold"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("healthy_threshold"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, healthyThresholdProp)) { |
| obj["healthyThreshold"] = healthyThresholdProp |
| } |
| nameProp, err := expandComputeRegionHealthCheckName(d.Get("name"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, nameProp)) { |
| obj["name"] = nameProp |
| } |
| unhealthyThresholdProp, err := expandComputeRegionHealthCheckUnhealthyThreshold(d.Get("unhealthy_threshold"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("unhealthy_threshold"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, unhealthyThresholdProp)) { |
| obj["unhealthyThreshold"] = unhealthyThresholdProp |
| } |
| timeoutSecProp, err := expandComputeRegionHealthCheckTimeoutSec(d.Get("timeout_sec"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("timeout_sec"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, timeoutSecProp)) { |
| obj["timeoutSec"] = timeoutSecProp |
| } |
| httpHealthCheckProp, err := expandComputeRegionHealthCheckHttpHealthCheck(d.Get("http_health_check"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("http_health_check"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, httpHealthCheckProp)) { |
| obj["httpHealthCheck"] = httpHealthCheckProp |
| } |
| httpsHealthCheckProp, err := expandComputeRegionHealthCheckHttpsHealthCheck(d.Get("https_health_check"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("https_health_check"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, httpsHealthCheckProp)) { |
| obj["httpsHealthCheck"] = httpsHealthCheckProp |
| } |
| tcpHealthCheckProp, err := expandComputeRegionHealthCheckTcpHealthCheck(d.Get("tcp_health_check"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("tcp_health_check"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, tcpHealthCheckProp)) { |
| obj["tcpHealthCheck"] = tcpHealthCheckProp |
| } |
| sslHealthCheckProp, err := expandComputeRegionHealthCheckSslHealthCheck(d.Get("ssl_health_check"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("ssl_health_check"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, sslHealthCheckProp)) { |
| obj["sslHealthCheck"] = sslHealthCheckProp |
| } |
| http2HealthCheckProp, err := expandComputeRegionHealthCheckHttp2HealthCheck(d.Get("http2_health_check"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("http2_health_check"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, http2HealthCheckProp)) { |
| obj["http2HealthCheck"] = http2HealthCheckProp |
| } |
| grpcHealthCheckProp, err := expandComputeRegionHealthCheckGrpcHealthCheck(d.Get("grpc_health_check"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("grpc_health_check"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, grpcHealthCheckProp)) { |
| obj["grpcHealthCheck"] = grpcHealthCheckProp |
| } |
| logConfigProp, err := expandComputeRegionHealthCheckLogConfig(d.Get("log_config"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("log_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, logConfigProp)) { |
| obj["logConfig"] = logConfigProp |
| } |
| regionProp, err := expandComputeRegionHealthCheckRegion(d.Get("region"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("region"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, regionProp)) { |
| obj["region"] = regionProp |
| } |
| |
| obj, err = resourceComputeRegionHealthCheckEncoder(d, meta, obj) |
| if err != nil { |
| return err |
| } |
| |
| url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/healthChecks/{{name}}") |
| if err != nil { |
| return err |
| } |
| |
| log.Printf("[DEBUG] Updating RegionHealthCheck %q: %#v", d.Id(), obj) |
| |
| // err == nil indicates that the billing_project value was found |
| if bp, err := tpgresource.GetBillingProject(d, config); err == nil { |
| billingProject = bp |
| } |
| |
| res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ |
| Config: config, |
| Method: "PUT", |
| Project: billingProject, |
| RawURL: url, |
| UserAgent: userAgent, |
| Body: obj, |
| Timeout: d.Timeout(schema.TimeoutUpdate), |
| }) |
| |
| if err != nil { |
| return fmt.Errorf("Error updating RegionHealthCheck %q: %s", d.Id(), err) |
| } else { |
| log.Printf("[DEBUG] Finished updating RegionHealthCheck %q: %#v", d.Id(), res) |
| } |
| |
| err = ComputeOperationWaitTime( |
| config, res, project, "Updating RegionHealthCheck", userAgent, |
| d.Timeout(schema.TimeoutUpdate)) |
| |
| if err != nil { |
| return err |
| } |
| |
| return resourceComputeRegionHealthCheckRead(d, meta) |
| } |
| |
| func resourceComputeRegionHealthCheckDelete(d *schema.ResourceData, meta interface{}) error { |
| config := meta.(*transport_tpg.Config) |
| userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) |
| if err != nil { |
| return err |
| } |
| |
| billingProject := "" |
| |
| project, err := tpgresource.GetProject(d, config) |
| if err != nil { |
| return fmt.Errorf("Error fetching project for RegionHealthCheck: %s", err) |
| } |
| billingProject = project |
| |
| url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/healthChecks/{{name}}") |
| if err != nil { |
| return err |
| } |
| |
| var obj map[string]interface{} |
| log.Printf("[DEBUG] Deleting RegionHealthCheck %q", d.Id()) |
| |
| // err == nil indicates that the billing_project value was found |
| if bp, err := tpgresource.GetBillingProject(d, config); err == nil { |
| billingProject = bp |
| } |
| |
| res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ |
| Config: config, |
| Method: "DELETE", |
| Project: billingProject, |
| RawURL: url, |
| UserAgent: userAgent, |
| Body: obj, |
| Timeout: d.Timeout(schema.TimeoutDelete), |
| }) |
| if err != nil { |
| return transport_tpg.HandleNotFoundError(err, d, "RegionHealthCheck") |
| } |
| |
| err = ComputeOperationWaitTime( |
| config, res, project, "Deleting RegionHealthCheck", userAgent, |
| d.Timeout(schema.TimeoutDelete)) |
| |
| if err != nil { |
| return err |
| } |
| |
| log.Printf("[DEBUG] Finished deleting RegionHealthCheck %q: %#v", d.Id(), res) |
| return nil |
| } |
| |
| func resourceComputeRegionHealthCheckImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { |
| config := meta.(*transport_tpg.Config) |
| if err := tpgresource.ParseImportId([]string{ |
| "^projects/(?P<project>[^/]+)/regions/(?P<region>[^/]+)/healthChecks/(?P<name>[^/]+)$", |
| "^(?P<project>[^/]+)/(?P<region>[^/]+)/(?P<name>[^/]+)$", |
| "^(?P<region>[^/]+)/(?P<name>[^/]+)$", |
| "^(?P<name>[^/]+)$", |
| }, d, config); err != nil { |
| return nil, err |
| } |
| |
| // Replace import id for the resource id |
| id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/regions/{{region}}/healthChecks/{{name}}") |
| if err != nil { |
| return nil, fmt.Errorf("Error constructing id: %s", err) |
| } |
| d.SetId(id) |
| |
| return []*schema.ResourceData{d}, nil |
| } |
| |
| func flattenComputeRegionHealthCheckCheckIntervalSec(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenComputeRegionHealthCheckCreationTimestamp(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHealthyThreshold(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenComputeRegionHealthCheckName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckUnhealthyThreshold(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenComputeRegionHealthCheckTimeoutSec(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenComputeRegionHealthCheckType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttpHealthCheck(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| if v == nil { |
| return nil |
| } |
| original := v.(map[string]interface{}) |
| if len(original) == 0 { |
| return nil |
| } |
| transformed := make(map[string]interface{}) |
| transformed["host"] = |
| flattenComputeRegionHealthCheckHttpHealthCheckHost(original["host"], d, config) |
| transformed["request_path"] = |
| flattenComputeRegionHealthCheckHttpHealthCheckRequestPath(original["requestPath"], d, config) |
| transformed["response"] = |
| flattenComputeRegionHealthCheckHttpHealthCheckResponse(original["response"], d, config) |
| transformed["port"] = |
| flattenComputeRegionHealthCheckHttpHealthCheckPort(original["port"], d, config) |
| transformed["port_name"] = |
| flattenComputeRegionHealthCheckHttpHealthCheckPortName(original["portName"], d, config) |
| transformed["proxy_header"] = |
| flattenComputeRegionHealthCheckHttpHealthCheckProxyHeader(original["proxyHeader"], d, config) |
| transformed["port_specification"] = |
| flattenComputeRegionHealthCheckHttpHealthCheckPortSpecification(original["portSpecification"], d, config) |
| return []interface{}{transformed} |
| } |
| func flattenComputeRegionHealthCheckHttpHealthCheckHost(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttpHealthCheckRequestPath(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttpHealthCheckResponse(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttpHealthCheckPort(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenComputeRegionHealthCheckHttpHealthCheckPortName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttpHealthCheckProxyHeader(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttpHealthCheckPortSpecification(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttpsHealthCheck(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| if v == nil { |
| return nil |
| } |
| original := v.(map[string]interface{}) |
| if len(original) == 0 { |
| return nil |
| } |
| transformed := make(map[string]interface{}) |
| transformed["host"] = |
| flattenComputeRegionHealthCheckHttpsHealthCheckHost(original["host"], d, config) |
| transformed["request_path"] = |
| flattenComputeRegionHealthCheckHttpsHealthCheckRequestPath(original["requestPath"], d, config) |
| transformed["response"] = |
| flattenComputeRegionHealthCheckHttpsHealthCheckResponse(original["response"], d, config) |
| transformed["port"] = |
| flattenComputeRegionHealthCheckHttpsHealthCheckPort(original["port"], d, config) |
| transformed["port_name"] = |
| flattenComputeRegionHealthCheckHttpsHealthCheckPortName(original["portName"], d, config) |
| transformed["proxy_header"] = |
| flattenComputeRegionHealthCheckHttpsHealthCheckProxyHeader(original["proxyHeader"], d, config) |
| transformed["port_specification"] = |
| flattenComputeRegionHealthCheckHttpsHealthCheckPortSpecification(original["portSpecification"], d, config) |
| return []interface{}{transformed} |
| } |
| func flattenComputeRegionHealthCheckHttpsHealthCheckHost(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttpsHealthCheckRequestPath(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttpsHealthCheckResponse(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttpsHealthCheckPort(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenComputeRegionHealthCheckHttpsHealthCheckPortName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttpsHealthCheckProxyHeader(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttpsHealthCheckPortSpecification(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckTcpHealthCheck(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| if v == nil { |
| return nil |
| } |
| original := v.(map[string]interface{}) |
| if len(original) == 0 { |
| return nil |
| } |
| transformed := make(map[string]interface{}) |
| transformed["request"] = |
| flattenComputeRegionHealthCheckTcpHealthCheckRequest(original["request"], d, config) |
| transformed["response"] = |
| flattenComputeRegionHealthCheckTcpHealthCheckResponse(original["response"], d, config) |
| transformed["port"] = |
| flattenComputeRegionHealthCheckTcpHealthCheckPort(original["port"], d, config) |
| transformed["port_name"] = |
| flattenComputeRegionHealthCheckTcpHealthCheckPortName(original["portName"], d, config) |
| transformed["proxy_header"] = |
| flattenComputeRegionHealthCheckTcpHealthCheckProxyHeader(original["proxyHeader"], d, config) |
| transformed["port_specification"] = |
| flattenComputeRegionHealthCheckTcpHealthCheckPortSpecification(original["portSpecification"], d, config) |
| return []interface{}{transformed} |
| } |
| func flattenComputeRegionHealthCheckTcpHealthCheckRequest(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckTcpHealthCheckResponse(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckTcpHealthCheckPort(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenComputeRegionHealthCheckTcpHealthCheckPortName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckTcpHealthCheckProxyHeader(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckTcpHealthCheckPortSpecification(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckSslHealthCheck(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| if v == nil { |
| return nil |
| } |
| original := v.(map[string]interface{}) |
| if len(original) == 0 { |
| return nil |
| } |
| transformed := make(map[string]interface{}) |
| transformed["request"] = |
| flattenComputeRegionHealthCheckSslHealthCheckRequest(original["request"], d, config) |
| transformed["response"] = |
| flattenComputeRegionHealthCheckSslHealthCheckResponse(original["response"], d, config) |
| transformed["port"] = |
| flattenComputeRegionHealthCheckSslHealthCheckPort(original["port"], d, config) |
| transformed["port_name"] = |
| flattenComputeRegionHealthCheckSslHealthCheckPortName(original["portName"], d, config) |
| transformed["proxy_header"] = |
| flattenComputeRegionHealthCheckSslHealthCheckProxyHeader(original["proxyHeader"], d, config) |
| transformed["port_specification"] = |
| flattenComputeRegionHealthCheckSslHealthCheckPortSpecification(original["portSpecification"], d, config) |
| return []interface{}{transformed} |
| } |
| func flattenComputeRegionHealthCheckSslHealthCheckRequest(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckSslHealthCheckResponse(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckSslHealthCheckPort(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenComputeRegionHealthCheckSslHealthCheckPortName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckSslHealthCheckProxyHeader(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckSslHealthCheckPortSpecification(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttp2HealthCheck(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| if v == nil { |
| return nil |
| } |
| original := v.(map[string]interface{}) |
| if len(original) == 0 { |
| return nil |
| } |
| transformed := make(map[string]interface{}) |
| transformed["host"] = |
| flattenComputeRegionHealthCheckHttp2HealthCheckHost(original["host"], d, config) |
| transformed["request_path"] = |
| flattenComputeRegionHealthCheckHttp2HealthCheckRequestPath(original["requestPath"], d, config) |
| transformed["response"] = |
| flattenComputeRegionHealthCheckHttp2HealthCheckResponse(original["response"], d, config) |
| transformed["port"] = |
| flattenComputeRegionHealthCheckHttp2HealthCheckPort(original["port"], d, config) |
| transformed["port_name"] = |
| flattenComputeRegionHealthCheckHttp2HealthCheckPortName(original["portName"], d, config) |
| transformed["proxy_header"] = |
| flattenComputeRegionHealthCheckHttp2HealthCheckProxyHeader(original["proxyHeader"], d, config) |
| transformed["port_specification"] = |
| flattenComputeRegionHealthCheckHttp2HealthCheckPortSpecification(original["portSpecification"], d, config) |
| return []interface{}{transformed} |
| } |
| func flattenComputeRegionHealthCheckHttp2HealthCheckHost(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttp2HealthCheckRequestPath(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttp2HealthCheckResponse(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttp2HealthCheckPort(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenComputeRegionHealthCheckHttp2HealthCheckPortName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttp2HealthCheckProxyHeader(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckHttp2HealthCheckPortSpecification(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckGrpcHealthCheck(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| if v == nil { |
| return nil |
| } |
| original := v.(map[string]interface{}) |
| if len(original) == 0 { |
| return nil |
| } |
| transformed := make(map[string]interface{}) |
| transformed["port"] = |
| flattenComputeRegionHealthCheckGrpcHealthCheckPort(original["port"], d, config) |
| transformed["port_name"] = |
| flattenComputeRegionHealthCheckGrpcHealthCheckPortName(original["portName"], d, config) |
| transformed["port_specification"] = |
| flattenComputeRegionHealthCheckGrpcHealthCheckPortSpecification(original["portSpecification"], d, config) |
| transformed["grpc_service_name"] = |
| flattenComputeRegionHealthCheckGrpcHealthCheckGrpcServiceName(original["grpcServiceName"], d, config) |
| return []interface{}{transformed} |
| } |
| func flattenComputeRegionHealthCheckGrpcHealthCheckPort(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenComputeRegionHealthCheckGrpcHealthCheckPortName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckGrpcHealthCheckPortSpecification(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckGrpcHealthCheckGrpcServiceName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenComputeRegionHealthCheckLogConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| transformed := make(map[string]interface{}) |
| if v == nil { |
| // Disabled by default, but API will not return object if value is false |
| transformed["enable"] = false |
| return []interface{}{transformed} |
| } |
| |
| original := v.(map[string]interface{}) |
| transformed["enable"] = original["enable"] |
| return []interface{}{transformed} |
| } |
| |
| func flattenComputeRegionHealthCheckRegion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| if v == nil { |
| return v |
| } |
| return tpgresource.NameFromSelfLinkStateFunc(v) |
| } |
| |
| func expandComputeRegionHealthCheckCheckIntervalSec(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHealthyThreshold(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckUnhealthyThreshold(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckTimeoutSec(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttpHealthCheck(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedHost, err := expandComputeRegionHealthCheckHttpHealthCheckHost(original["host"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedHost); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["host"] = transformedHost |
| } |
| |
| transformedRequestPath, err := expandComputeRegionHealthCheckHttpHealthCheckRequestPath(original["request_path"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedRequestPath); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["requestPath"] = transformedRequestPath |
| } |
| |
| transformedResponse, err := expandComputeRegionHealthCheckHttpHealthCheckResponse(original["response"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedResponse); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["response"] = transformedResponse |
| } |
| |
| transformedPort, err := expandComputeRegionHealthCheckHttpHealthCheckPort(original["port"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPort); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["port"] = transformedPort |
| } |
| |
| transformedPortName, err := expandComputeRegionHealthCheckHttpHealthCheckPortName(original["port_name"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPortName); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["portName"] = transformedPortName |
| } |
| |
| transformedProxyHeader, err := expandComputeRegionHealthCheckHttpHealthCheckProxyHeader(original["proxy_header"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedProxyHeader); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["proxyHeader"] = transformedProxyHeader |
| } |
| |
| transformedPortSpecification, err := expandComputeRegionHealthCheckHttpHealthCheckPortSpecification(original["port_specification"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPortSpecification); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["portSpecification"] = transformedPortSpecification |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttpHealthCheckHost(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttpHealthCheckRequestPath(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttpHealthCheckResponse(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttpHealthCheckPort(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttpHealthCheckPortName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttpHealthCheckProxyHeader(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttpHealthCheckPortSpecification(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttpsHealthCheck(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedHost, err := expandComputeRegionHealthCheckHttpsHealthCheckHost(original["host"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedHost); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["host"] = transformedHost |
| } |
| |
| transformedRequestPath, err := expandComputeRegionHealthCheckHttpsHealthCheckRequestPath(original["request_path"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedRequestPath); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["requestPath"] = transformedRequestPath |
| } |
| |
| transformedResponse, err := expandComputeRegionHealthCheckHttpsHealthCheckResponse(original["response"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedResponse); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["response"] = transformedResponse |
| } |
| |
| transformedPort, err := expandComputeRegionHealthCheckHttpsHealthCheckPort(original["port"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPort); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["port"] = transformedPort |
| } |
| |
| transformedPortName, err := expandComputeRegionHealthCheckHttpsHealthCheckPortName(original["port_name"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPortName); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["portName"] = transformedPortName |
| } |
| |
| transformedProxyHeader, err := expandComputeRegionHealthCheckHttpsHealthCheckProxyHeader(original["proxy_header"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedProxyHeader); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["proxyHeader"] = transformedProxyHeader |
| } |
| |
| transformedPortSpecification, err := expandComputeRegionHealthCheckHttpsHealthCheckPortSpecification(original["port_specification"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPortSpecification); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["portSpecification"] = transformedPortSpecification |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttpsHealthCheckHost(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttpsHealthCheckRequestPath(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttpsHealthCheckResponse(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttpsHealthCheckPort(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttpsHealthCheckPortName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttpsHealthCheckProxyHeader(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttpsHealthCheckPortSpecification(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckTcpHealthCheck(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedRequest, err := expandComputeRegionHealthCheckTcpHealthCheckRequest(original["request"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedRequest); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["request"] = transformedRequest |
| } |
| |
| transformedResponse, err := expandComputeRegionHealthCheckTcpHealthCheckResponse(original["response"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedResponse); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["response"] = transformedResponse |
| } |
| |
| transformedPort, err := expandComputeRegionHealthCheckTcpHealthCheckPort(original["port"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPort); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["port"] = transformedPort |
| } |
| |
| transformedPortName, err := expandComputeRegionHealthCheckTcpHealthCheckPortName(original["port_name"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPortName); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["portName"] = transformedPortName |
| } |
| |
| transformedProxyHeader, err := expandComputeRegionHealthCheckTcpHealthCheckProxyHeader(original["proxy_header"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedProxyHeader); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["proxyHeader"] = transformedProxyHeader |
| } |
| |
| transformedPortSpecification, err := expandComputeRegionHealthCheckTcpHealthCheckPortSpecification(original["port_specification"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPortSpecification); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["portSpecification"] = transformedPortSpecification |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandComputeRegionHealthCheckTcpHealthCheckRequest(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckTcpHealthCheckResponse(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckTcpHealthCheckPort(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckTcpHealthCheckPortName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckTcpHealthCheckProxyHeader(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckTcpHealthCheckPortSpecification(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckSslHealthCheck(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedRequest, err := expandComputeRegionHealthCheckSslHealthCheckRequest(original["request"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedRequest); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["request"] = transformedRequest |
| } |
| |
| transformedResponse, err := expandComputeRegionHealthCheckSslHealthCheckResponse(original["response"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedResponse); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["response"] = transformedResponse |
| } |
| |
| transformedPort, err := expandComputeRegionHealthCheckSslHealthCheckPort(original["port"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPort); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["port"] = transformedPort |
| } |
| |
| transformedPortName, err := expandComputeRegionHealthCheckSslHealthCheckPortName(original["port_name"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPortName); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["portName"] = transformedPortName |
| } |
| |
| transformedProxyHeader, err := expandComputeRegionHealthCheckSslHealthCheckProxyHeader(original["proxy_header"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedProxyHeader); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["proxyHeader"] = transformedProxyHeader |
| } |
| |
| transformedPortSpecification, err := expandComputeRegionHealthCheckSslHealthCheckPortSpecification(original["port_specification"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPortSpecification); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["portSpecification"] = transformedPortSpecification |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandComputeRegionHealthCheckSslHealthCheckRequest(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckSslHealthCheckResponse(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckSslHealthCheckPort(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckSslHealthCheckPortName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckSslHealthCheckProxyHeader(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckSslHealthCheckPortSpecification(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttp2HealthCheck(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedHost, err := expandComputeRegionHealthCheckHttp2HealthCheckHost(original["host"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedHost); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["host"] = transformedHost |
| } |
| |
| transformedRequestPath, err := expandComputeRegionHealthCheckHttp2HealthCheckRequestPath(original["request_path"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedRequestPath); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["requestPath"] = transformedRequestPath |
| } |
| |
| transformedResponse, err := expandComputeRegionHealthCheckHttp2HealthCheckResponse(original["response"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedResponse); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["response"] = transformedResponse |
| } |
| |
| transformedPort, err := expandComputeRegionHealthCheckHttp2HealthCheckPort(original["port"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPort); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["port"] = transformedPort |
| } |
| |
| transformedPortName, err := expandComputeRegionHealthCheckHttp2HealthCheckPortName(original["port_name"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPortName); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["portName"] = transformedPortName |
| } |
| |
| transformedProxyHeader, err := expandComputeRegionHealthCheckHttp2HealthCheckProxyHeader(original["proxy_header"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedProxyHeader); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["proxyHeader"] = transformedProxyHeader |
| } |
| |
| transformedPortSpecification, err := expandComputeRegionHealthCheckHttp2HealthCheckPortSpecification(original["port_specification"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPortSpecification); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["portSpecification"] = transformedPortSpecification |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttp2HealthCheckHost(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttp2HealthCheckRequestPath(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttp2HealthCheckResponse(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttp2HealthCheckPort(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttp2HealthCheckPortName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttp2HealthCheckProxyHeader(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckHttp2HealthCheckPortSpecification(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckGrpcHealthCheck(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedPort, err := expandComputeRegionHealthCheckGrpcHealthCheckPort(original["port"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPort); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["port"] = transformedPort |
| } |
| |
| transformedPortName, err := expandComputeRegionHealthCheckGrpcHealthCheckPortName(original["port_name"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPortName); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["portName"] = transformedPortName |
| } |
| |
| transformedPortSpecification, err := expandComputeRegionHealthCheckGrpcHealthCheckPortSpecification(original["port_specification"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedPortSpecification); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["portSpecification"] = transformedPortSpecification |
| } |
| |
| transformedGrpcServiceName, err := expandComputeRegionHealthCheckGrpcHealthCheckGrpcServiceName(original["grpc_service_name"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedGrpcServiceName); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["grpcServiceName"] = transformedGrpcServiceName |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandComputeRegionHealthCheckGrpcHealthCheckPort(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckGrpcHealthCheckPortName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckGrpcHealthCheckPortSpecification(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckGrpcHealthCheckGrpcServiceName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckLogConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedEnable, err := expandComputeRegionHealthCheckLogConfigEnable(original["enable"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedEnable); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["enable"] = transformedEnable |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandComputeRegionHealthCheckLogConfigEnable(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandComputeRegionHealthCheckRegion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| f, err := tpgresource.ParseGlobalFieldValue("regions", v.(string), "project", d, config, true) |
| if err != nil { |
| return nil, fmt.Errorf("Invalid value for region: %s", err) |
| } |
| return f.RelativeLink(), nil |
| } |
| |
| func resourceComputeRegionHealthCheckEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { |
| |
| if _, ok := d.GetOk("http_health_check"); ok { |
| hc := d.Get("http_health_check").([]interface{})[0] |
| ps := hc.(map[string]interface{})["port_specification"] |
| pn := hc.(map[string]interface{})["port_name"] |
| |
| if ps == "USE_FIXED_PORT" || (ps == "" && pn == "") { |
| m := obj["httpHealthCheck"].(map[string]interface{}) |
| if m["port"] == nil { |
| m["port"] = 80 |
| } |
| } |
| obj["type"] = "HTTP" |
| return obj, nil |
| } |
| if _, ok := d.GetOk("https_health_check"); ok { |
| hc := d.Get("https_health_check").([]interface{})[0] |
| ps := hc.(map[string]interface{})["port_specification"] |
| pn := hc.(map[string]interface{})["port_name"] |
| |
| if ps == "USE_FIXED_PORT" || (ps == "" && pn == "") { |
| m := obj["httpsHealthCheck"].(map[string]interface{}) |
| if m["port"] == nil { |
| m["port"] = 443 |
| } |
| } |
| obj["type"] = "HTTPS" |
| return obj, nil |
| } |
| if _, ok := d.GetOk("http2_health_check"); ok { |
| hc := d.Get("http2_health_check").([]interface{})[0] |
| ps := hc.(map[string]interface{})["port_specification"] |
| pn := hc.(map[string]interface{})["port_name"] |
| |
| if ps == "USE_FIXED_PORT" || (ps == "" && pn == "") { |
| m := obj["http2HealthCheck"].(map[string]interface{}) |
| if m["port"] == nil { |
| m["port"] = 443 |
| } |
| } |
| obj["type"] = "HTTP2" |
| return obj, nil |
| } |
| if _, ok := d.GetOk("tcp_health_check"); ok { |
| hc := d.Get("tcp_health_check").([]interface{})[0] |
| ps := hc.(map[string]interface{})["port_specification"] |
| pn := hc.(map[string]interface{})["port_name"] |
| |
| if ps == "USE_FIXED_PORT" || (ps == "" && pn == "") { |
| m := obj["tcpHealthCheck"].(map[string]interface{}) |
| if m["port"] == nil { |
| m["port"] = 80 |
| } |
| } |
| obj["type"] = "TCP" |
| return obj, nil |
| } |
| if _, ok := d.GetOk("ssl_health_check"); ok { |
| hc := d.Get("ssl_health_check").([]interface{})[0] |
| ps := hc.(map[string]interface{})["port_specification"] |
| pn := hc.(map[string]interface{})["port_name"] |
| |
| if ps == "USE_FIXED_PORT" || (ps == "" && pn == "") { |
| m := obj["sslHealthCheck"].(map[string]interface{}) |
| if m["port"] == nil { |
| m["port"] = 443 |
| } |
| } |
| obj["type"] = "SSL" |
| return obj, nil |
| } |
| |
| if _, ok := d.GetOk("grpc_health_check"); ok { |
| hc := d.Get("grpc_health_check").([]interface{})[0] |
| ps := hc.(map[string]interface{})["port_specification"] |
| pn := hc.(map[string]interface{})["port_name"] |
| |
| if ps == "USE_FIXED_PORT" || (ps == "" && pn == "") { |
| m := obj["grpcHealthCheck"].(map[string]interface{}) |
| if m["port"] == nil { |
| return nil, fmt.Errorf("error in HealthCheck %s: `port` must be set for GRPC health checks`.", d.Get("name").(string)) |
| } |
| } |
| obj["type"] = "GRPC" |
| return obj, nil |
| } |
| |
| return nil, fmt.Errorf("error in HealthCheck %s: No health check block specified.", d.Get("name").(string)) |
| } |