2018-03-10 01:14:32 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
|
|
|
|
//
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
//
|
2018-04-12 23:08:42 +00:00
|
|
|
// This file is automatically generated by Magic Modules and manual
|
|
|
|
// changes will be clobbered when the file is regenerated.
|
2018-03-10 01:14:32 +00:00
|
|
|
//
|
|
|
|
// Please read more about how to change this file in
|
|
|
|
// .github/CONTRIBUTING.md.
|
|
|
|
//
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2015-11-12 15:48:26 +00:00
|
|
|
package google
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
2018-06-19 20:56:06 +00:00
|
|
|
"reflect"
|
2018-04-24 21:01:53 +00:00
|
|
|
"strconv"
|
2018-03-10 01:14:32 +00:00
|
|
|
"time"
|
2015-11-12 15:48:26 +00:00
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
2018-03-10 01:14:32 +00:00
|
|
|
compute "google.golang.org/api/compute/v1"
|
2015-11-12 15:48:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func resourceComputeHttpsHealthCheck() *schema.Resource {
|
|
|
|
return &schema.Resource{
|
|
|
|
Create: resourceComputeHttpsHealthCheckCreate,
|
|
|
|
Read: resourceComputeHttpsHealthCheckRead,
|
|
|
|
Update: resourceComputeHttpsHealthCheckUpdate,
|
2018-03-10 01:14:32 +00:00
|
|
|
Delete: resourceComputeHttpsHealthCheckDelete,
|
|
|
|
|
2017-07-18 18:35:24 +00:00
|
|
|
Importer: &schema.ResourceImporter{
|
2018-03-10 01:14:32 +00:00
|
|
|
State: resourceComputeHttpsHealthCheckImport,
|
|
|
|
},
|
|
|
|
|
|
|
|
Timeouts: &schema.ResourceTimeout{
|
2018-04-12 23:08:42 +00:00
|
|
|
Create: schema.DefaultTimeout(240 * time.Second),
|
|
|
|
Update: schema.DefaultTimeout(240 * time.Second),
|
|
|
|
Delete: schema.DefaultTimeout(240 * time.Second),
|
2017-07-18 18:35:24 +00:00
|
|
|
},
|
2015-11-12 15:48:26 +00:00
|
|
|
|
|
|
|
Schema: map[string]*schema.Schema{
|
2018-03-10 01:14:32 +00:00
|
|
|
"name": {
|
2016-04-10 21:34:15 +00:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
ForceNew: true,
|
|
|
|
},
|
2018-03-10 01:14:32 +00:00
|
|
|
"check_interval_sec": {
|
2015-11-12 15:48:26 +00:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
Optional: true,
|
|
|
|
Default: 5,
|
|
|
|
},
|
2018-03-10 01:14:32 +00:00
|
|
|
"description": {
|
2015-11-12 15:48:26 +00:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Optional: true,
|
|
|
|
},
|
2018-03-10 01:14:32 +00:00
|
|
|
"healthy_threshold": {
|
2015-11-12 15:48:26 +00:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
Optional: true,
|
|
|
|
Default: 2,
|
|
|
|
},
|
2018-03-10 01:14:32 +00:00
|
|
|
"host": {
|
2015-11-12 15:48:26 +00:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Optional: true,
|
|
|
|
},
|
2018-03-10 01:14:32 +00:00
|
|
|
"port": {
|
2015-11-12 15:48:26 +00:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
Optional: true,
|
|
|
|
Default: 443,
|
|
|
|
},
|
2018-03-10 01:14:32 +00:00
|
|
|
"request_path": {
|
2015-11-12 15:48:26 +00:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Optional: true,
|
|
|
|
Default: "/",
|
|
|
|
},
|
2018-03-10 01:14:32 +00:00
|
|
|
"timeout_sec": {
|
2015-11-12 15:48:26 +00:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
Optional: true,
|
|
|
|
Default: 5,
|
|
|
|
},
|
2018-03-10 01:14:32 +00:00
|
|
|
"unhealthy_threshold": {
|
2015-11-12 15:48:26 +00:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
Optional: true,
|
|
|
|
Default: 2,
|
|
|
|
},
|
2018-03-10 01:14:32 +00:00
|
|
|
"creation_timestamp": {
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Computed: true,
|
|
|
|
},
|
2018-04-24 23:39:20 +00:00
|
|
|
"project": {
|
2018-03-10 01:14:32 +00:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Optional: true,
|
|
|
|
Computed: true,
|
|
|
|
ForceNew: true,
|
|
|
|
},
|
2018-04-24 23:39:20 +00:00
|
|
|
"self_link": {
|
2018-03-10 01:14:32 +00:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Computed: true,
|
|
|
|
},
|
2015-11-12 15:48:26 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func resourceComputeHttpsHealthCheckCreate(d *schema.ResourceData, meta interface{}) error {
|
|
|
|
config := meta.(*Config)
|
|
|
|
|
2016-04-10 16:59:57 +00:00
|
|
|
project, err := getProject(d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-06-19 20:56:06 +00:00
|
|
|
obj := make(map[string]interface{})
|
2018-04-23 23:19:26 +00:00
|
|
|
checkIntervalSecProp, err := expandComputeHttpsHealthCheckCheckIntervalSec(d.Get("check_interval_sec"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-22 00:46:50 +00:00
|
|
|
} else if v, ok := d.GetOkExists("check_interval_sec"); !isEmptyValue(reflect.ValueOf(checkIntervalSecProp)) && (ok || !reflect.DeepEqual(v, checkIntervalSecProp)) {
|
2018-06-19 20:56:06 +00:00
|
|
|
obj["checkIntervalSec"] = checkIntervalSecProp
|
2018-04-23 23:19:26 +00:00
|
|
|
}
|
|
|
|
descriptionProp, err := expandComputeHttpsHealthCheckDescription(d.Get("description"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-22 00:46:50 +00:00
|
|
|
} else if v, ok := d.GetOkExists("description"); !isEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) {
|
2018-06-19 20:56:06 +00:00
|
|
|
obj["description"] = descriptionProp
|
2018-04-23 23:19:26 +00:00
|
|
|
}
|
|
|
|
healthyThresholdProp, err := expandComputeHttpsHealthCheckHealthyThreshold(d.Get("healthy_threshold"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-22 00:46:50 +00:00
|
|
|
} else if v, ok := d.GetOkExists("healthy_threshold"); !isEmptyValue(reflect.ValueOf(healthyThresholdProp)) && (ok || !reflect.DeepEqual(v, healthyThresholdProp)) {
|
2018-06-19 20:56:06 +00:00
|
|
|
obj["healthyThreshold"] = healthyThresholdProp
|
2018-04-23 23:19:26 +00:00
|
|
|
}
|
|
|
|
hostProp, err := expandComputeHttpsHealthCheckHost(d.Get("host"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-22 00:46:50 +00:00
|
|
|
} else if v, ok := d.GetOkExists("host"); !isEmptyValue(reflect.ValueOf(hostProp)) && (ok || !reflect.DeepEqual(v, hostProp)) {
|
2018-06-19 20:56:06 +00:00
|
|
|
obj["host"] = hostProp
|
2018-04-23 23:19:26 +00:00
|
|
|
}
|
|
|
|
nameProp, err := expandComputeHttpsHealthCheckName(d.Get("name"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-22 00:46:50 +00:00
|
|
|
} else if v, ok := d.GetOkExists("name"); !isEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) {
|
2018-06-19 20:56:06 +00:00
|
|
|
obj["name"] = nameProp
|
2018-04-23 23:19:26 +00:00
|
|
|
}
|
|
|
|
portProp, err := expandComputeHttpsHealthCheckPort(d.Get("port"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-22 00:46:50 +00:00
|
|
|
} else if v, ok := d.GetOkExists("port"); !isEmptyValue(reflect.ValueOf(portProp)) && (ok || !reflect.DeepEqual(v, portProp)) {
|
2018-06-19 20:56:06 +00:00
|
|
|
obj["port"] = portProp
|
2018-04-23 23:19:26 +00:00
|
|
|
}
|
|
|
|
requestPathProp, err := expandComputeHttpsHealthCheckRequestPath(d.Get("request_path"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-22 00:46:50 +00:00
|
|
|
} else if v, ok := d.GetOkExists("request_path"); !isEmptyValue(reflect.ValueOf(requestPathProp)) && (ok || !reflect.DeepEqual(v, requestPathProp)) {
|
2018-06-19 20:56:06 +00:00
|
|
|
obj["requestPath"] = requestPathProp
|
2018-04-23 23:19:26 +00:00
|
|
|
}
|
|
|
|
timeoutSecProp, err := expandComputeHttpsHealthCheckTimeoutSec(d.Get("timeout_sec"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-22 00:46:50 +00:00
|
|
|
} else if v, ok := d.GetOkExists("timeout_sec"); !isEmptyValue(reflect.ValueOf(timeoutSecProp)) && (ok || !reflect.DeepEqual(v, timeoutSecProp)) {
|
2018-06-19 20:56:06 +00:00
|
|
|
obj["timeoutSec"] = timeoutSecProp
|
2018-04-23 23:19:26 +00:00
|
|
|
}
|
|
|
|
unhealthyThresholdProp, err := expandComputeHttpsHealthCheckUnhealthyThreshold(d.Get("unhealthy_threshold"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-22 00:46:50 +00:00
|
|
|
} else if v, ok := d.GetOkExists("unhealthy_threshold"); !isEmptyValue(reflect.ValueOf(unhealthyThresholdProp)) && (ok || !reflect.DeepEqual(v, unhealthyThresholdProp)) {
|
2018-06-19 20:56:06 +00:00
|
|
|
obj["unhealthyThreshold"] = unhealthyThresholdProp
|
2015-11-12 15:48:26 +00:00
|
|
|
}
|
2018-03-10 01:14:32 +00:00
|
|
|
|
|
|
|
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/httpsHealthChecks")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2015-11-12 15:48:26 +00:00
|
|
|
}
|
|
|
|
|
2018-03-10 01:14:32 +00:00
|
|
|
log.Printf("[DEBUG] Creating new HttpsHealthCheck: %#v", obj)
|
|
|
|
res, err := Post(config, url, obj)
|
2015-11-12 15:48:26 +00:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("Error creating HttpsHealthCheck: %s", err)
|
|
|
|
}
|
|
|
|
|
2018-03-10 01:14:32 +00:00
|
|
|
// Store the ID now
|
|
|
|
id, err := replaceVars(d, config, "{{name}}")
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("Error constructing id: %s", err)
|
|
|
|
}
|
|
|
|
d.SetId(id)
|
2015-11-12 15:48:26 +00:00
|
|
|
|
2018-03-10 01:14:32 +00:00
|
|
|
op := &compute.Operation{}
|
|
|
|
err = Convert(res, op)
|
2015-11-12 15:48:26 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-03-10 01:14:32 +00:00
|
|
|
waitErr := computeOperationWaitTime(
|
|
|
|
config.clientCompute, op, project, "Creating HttpsHealthCheck",
|
|
|
|
int(d.Timeout(schema.TimeoutCreate).Minutes()))
|
|
|
|
|
|
|
|
if waitErr != nil {
|
|
|
|
// The resource didn't actually create
|
|
|
|
d.SetId("")
|
2018-05-01 20:48:56 +00:00
|
|
|
return fmt.Errorf("Error waiting to create HttpsHealthCheck: %s", waitErr)
|
2018-03-10 01:14:32 +00:00
|
|
|
}
|
|
|
|
|
2018-05-17 23:33:30 +00:00
|
|
|
log.Printf("[DEBUG] Finished creating HttpsHealthCheck %q: %#v", d.Id(), res)
|
|
|
|
|
2015-11-12 15:48:26 +00:00
|
|
|
return resourceComputeHttpsHealthCheckRead(d, meta)
|
|
|
|
}
|
|
|
|
|
2018-03-10 01:14:32 +00:00
|
|
|
func resourceComputeHttpsHealthCheckRead(d *schema.ResourceData, meta interface{}) error {
|
2015-11-12 15:48:26 +00:00
|
|
|
config := meta.(*Config)
|
|
|
|
|
2016-04-10 16:59:57 +00:00
|
|
|
project, err := getProject(d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-03-10 01:14:32 +00:00
|
|
|
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/httpsHealthChecks/{{name}}")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2015-11-12 15:48:26 +00:00
|
|
|
}
|
2018-03-10 01:14:32 +00:00
|
|
|
|
|
|
|
res, err := Get(config, url)
|
|
|
|
if err != nil {
|
|
|
|
return handleNotFoundError(err, d, fmt.Sprintf("ComputeHttpsHealthCheck %q", d.Id()))
|
2015-11-12 15:48:26 +00:00
|
|
|
}
|
2018-05-17 23:33:30 +00:00
|
|
|
|
2018-04-30 23:18:17 +00:00
|
|
|
if err := d.Set("check_interval_sec", flattenComputeHttpsHealthCheckCheckIntervalSec(res["checkIntervalSec"])); err != nil {
|
|
|
|
return fmt.Errorf("Error reading HttpsHealthCheck: %s", err)
|
|
|
|
}
|
|
|
|
if err := d.Set("creation_timestamp", flattenComputeHttpsHealthCheckCreationTimestamp(res["creationTimestamp"])); err != nil {
|
|
|
|
return fmt.Errorf("Error reading HttpsHealthCheck: %s", err)
|
|
|
|
}
|
|
|
|
if err := d.Set("description", flattenComputeHttpsHealthCheckDescription(res["description"])); err != nil {
|
|
|
|
return fmt.Errorf("Error reading HttpsHealthCheck: %s", err)
|
|
|
|
}
|
|
|
|
if err := d.Set("healthy_threshold", flattenComputeHttpsHealthCheckHealthyThreshold(res["healthyThreshold"])); err != nil {
|
|
|
|
return fmt.Errorf("Error reading HttpsHealthCheck: %s", err)
|
|
|
|
}
|
|
|
|
if err := d.Set("host", flattenComputeHttpsHealthCheckHost(res["host"])); err != nil {
|
|
|
|
return fmt.Errorf("Error reading HttpsHealthCheck: %s", err)
|
|
|
|
}
|
|
|
|
if err := d.Set("name", flattenComputeHttpsHealthCheckName(res["name"])); err != nil {
|
|
|
|
return fmt.Errorf("Error reading HttpsHealthCheck: %s", err)
|
|
|
|
}
|
|
|
|
if err := d.Set("port", flattenComputeHttpsHealthCheckPort(res["port"])); err != nil {
|
|
|
|
return fmt.Errorf("Error reading HttpsHealthCheck: %s", err)
|
|
|
|
}
|
|
|
|
if err := d.Set("request_path", flattenComputeHttpsHealthCheckRequestPath(res["requestPath"])); err != nil {
|
|
|
|
return fmt.Errorf("Error reading HttpsHealthCheck: %s", err)
|
|
|
|
}
|
|
|
|
if err := d.Set("timeout_sec", flattenComputeHttpsHealthCheckTimeoutSec(res["timeoutSec"])); err != nil {
|
|
|
|
return fmt.Errorf("Error reading HttpsHealthCheck: %s", err)
|
|
|
|
}
|
|
|
|
if err := d.Set("unhealthy_threshold", flattenComputeHttpsHealthCheckUnhealthyThreshold(res["unhealthyThreshold"])); err != nil {
|
|
|
|
return fmt.Errorf("Error reading HttpsHealthCheck: %s", err)
|
|
|
|
}
|
2018-06-12 00:31:33 +00:00
|
|
|
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
|
2018-04-30 23:18:17 +00:00
|
|
|
return fmt.Errorf("Error reading HttpsHealthCheck: %s", err)
|
|
|
|
}
|
|
|
|
if err := d.Set("project", project); err != nil {
|
|
|
|
return fmt.Errorf("Error reading HttpsHealthCheck: %s", err)
|
|
|
|
}
|
2018-03-10 01:14:32 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func resourceComputeHttpsHealthCheckUpdate(d *schema.ResourceData, meta interface{}) error {
|
|
|
|
config := meta.(*Config)
|
|
|
|
|
|
|
|
project, err := getProject(d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2015-11-12 15:48:26 +00:00
|
|
|
}
|
2018-03-10 01:14:32 +00:00
|
|
|
|
2018-06-19 20:56:06 +00:00
|
|
|
obj := make(map[string]interface{})
|
2018-04-23 23:19:26 +00:00
|
|
|
checkIntervalSecProp, err := expandComputeHttpsHealthCheckCheckIntervalSec(d.Get("check_interval_sec"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-19 20:56:06 +00:00
|
|
|
} else if v, ok := d.GetOkExists("check_interval_sec"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, checkIntervalSecProp)) {
|
|
|
|
obj["checkIntervalSec"] = checkIntervalSecProp
|
2018-04-23 23:19:26 +00:00
|
|
|
}
|
|
|
|
descriptionProp, err := expandComputeHttpsHealthCheckDescription(d.Get("description"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-19 20:56:06 +00:00
|
|
|
} else if v, ok := d.GetOkExists("description"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) {
|
|
|
|
obj["description"] = descriptionProp
|
2018-04-23 23:19:26 +00:00
|
|
|
}
|
|
|
|
healthyThresholdProp, err := expandComputeHttpsHealthCheckHealthyThreshold(d.Get("healthy_threshold"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-19 20:56:06 +00:00
|
|
|
} else if v, ok := d.GetOkExists("healthy_threshold"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, healthyThresholdProp)) {
|
|
|
|
obj["healthyThreshold"] = healthyThresholdProp
|
2018-04-23 23:19:26 +00:00
|
|
|
}
|
|
|
|
hostProp, err := expandComputeHttpsHealthCheckHost(d.Get("host"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-19 20:56:06 +00:00
|
|
|
} else if v, ok := d.GetOkExists("host"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, hostProp)) {
|
|
|
|
obj["host"] = hostProp
|
2018-04-23 23:19:26 +00:00
|
|
|
}
|
|
|
|
nameProp, err := expandComputeHttpsHealthCheckName(d.Get("name"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-19 20:56:06 +00:00
|
|
|
} else if v, ok := d.GetOkExists("name"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, nameProp)) {
|
|
|
|
obj["name"] = nameProp
|
2018-04-23 23:19:26 +00:00
|
|
|
}
|
|
|
|
portProp, err := expandComputeHttpsHealthCheckPort(d.Get("port"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-19 20:56:06 +00:00
|
|
|
} else if v, ok := d.GetOkExists("port"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, portProp)) {
|
|
|
|
obj["port"] = portProp
|
2018-04-23 23:19:26 +00:00
|
|
|
}
|
|
|
|
requestPathProp, err := expandComputeHttpsHealthCheckRequestPath(d.Get("request_path"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-19 20:56:06 +00:00
|
|
|
} else if v, ok := d.GetOkExists("request_path"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, requestPathProp)) {
|
|
|
|
obj["requestPath"] = requestPathProp
|
2018-04-23 23:19:26 +00:00
|
|
|
}
|
|
|
|
timeoutSecProp, err := expandComputeHttpsHealthCheckTimeoutSec(d.Get("timeout_sec"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-19 20:56:06 +00:00
|
|
|
} else if v, ok := d.GetOkExists("timeout_sec"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, timeoutSecProp)) {
|
|
|
|
obj["timeoutSec"] = timeoutSecProp
|
2018-04-23 23:19:26 +00:00
|
|
|
}
|
|
|
|
unhealthyThresholdProp, err := expandComputeHttpsHealthCheckUnhealthyThreshold(d.Get("unhealthy_threshold"), d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-19 20:56:06 +00:00
|
|
|
} else if v, ok := d.GetOkExists("unhealthy_threshold"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, unhealthyThresholdProp)) {
|
|
|
|
obj["unhealthyThreshold"] = unhealthyThresholdProp
|
2015-11-12 15:48:26 +00:00
|
|
|
}
|
2018-03-10 01:14:32 +00:00
|
|
|
|
|
|
|
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/httpsHealthChecks/{{name}}")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2015-11-12 15:48:26 +00:00
|
|
|
}
|
2018-03-10 01:14:32 +00:00
|
|
|
|
|
|
|
log.Printf("[DEBUG] Updating HttpsHealthCheck %q: %#v", d.Id(), obj)
|
|
|
|
res, err := sendRequest(config, "PUT", url, obj)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("Error updating HttpsHealthCheck %q: %s", d.Id(), err)
|
2015-11-12 15:48:26 +00:00
|
|
|
}
|
|
|
|
|
2018-03-10 01:14:32 +00:00
|
|
|
op := &compute.Operation{}
|
|
|
|
err = Convert(res, op)
|
2015-11-12 15:48:26 +00:00
|
|
|
if err != nil {
|
2018-03-10 01:14:32 +00:00
|
|
|
return err
|
2015-11-12 15:48:26 +00:00
|
|
|
}
|
|
|
|
|
2018-03-10 01:14:32 +00:00
|
|
|
err = computeOperationWaitTime(
|
|
|
|
config.clientCompute, op, project, "Updating HttpsHealthCheck",
|
|
|
|
int(d.Timeout(schema.TimeoutUpdate).Minutes()))
|
2015-11-12 15:48:26 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resourceComputeHttpsHealthCheckRead(d, meta)
|
|
|
|
}
|
|
|
|
|
2018-03-10 01:14:32 +00:00
|
|
|
func resourceComputeHttpsHealthCheckDelete(d *schema.ResourceData, meta interface{}) error {
|
2015-11-12 15:48:26 +00:00
|
|
|
config := meta.(*Config)
|
|
|
|
|
2016-04-10 16:59:57 +00:00
|
|
|
project, err := getProject(d, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-03-10 01:14:32 +00:00
|
|
|
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/httpsHealthChecks/{{name}}")
|
2015-11-12 15:48:26 +00:00
|
|
|
if err != nil {
|
2018-03-10 01:14:32 +00:00
|
|
|
return err
|
2015-11-12 15:48:26 +00:00
|
|
|
}
|
|
|
|
|
2018-03-10 01:14:32 +00:00
|
|
|
log.Printf("[DEBUG] Deleting HttpsHealthCheck %q", d.Id())
|
|
|
|
res, err := Delete(config, url)
|
2016-04-10 16:59:57 +00:00
|
|
|
if err != nil {
|
2018-06-02 20:33:30 +00:00
|
|
|
return handleNotFoundError(err, d, "HttpsHealthCheck")
|
2016-04-10 16:59:57 +00:00
|
|
|
}
|
|
|
|
|
2018-03-10 01:14:32 +00:00
|
|
|
op := &compute.Operation{}
|
|
|
|
err = Convert(res, op)
|
2015-11-12 15:48:26 +00:00
|
|
|
if err != nil {
|
2018-03-10 01:14:32 +00:00
|
|
|
return err
|
2015-11-12 15:48:26 +00:00
|
|
|
}
|
|
|
|
|
2018-03-10 01:14:32 +00:00
|
|
|
err = computeOperationWaitTime(
|
|
|
|
config.clientCompute, op, project, "Deleting HttpsHealthCheck",
|
|
|
|
int(d.Timeout(schema.TimeoutDelete).Minutes()))
|
|
|
|
|
2015-11-12 15:48:26 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-05-17 23:33:30 +00:00
|
|
|
log.Printf("[DEBUG] Finished deleting HttpsHealthCheck %q: %#v", d.Id(), res)
|
2015-11-12 15:48:26 +00:00
|
|
|
return nil
|
|
|
|
}
|
2018-03-10 01:14:32 +00:00
|
|
|
|
|
|
|
func resourceComputeHttpsHealthCheckImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
|
|
|
|
config := meta.(*Config)
|
|
|
|
parseImportId([]string{"projects/(?P<project>[^/]+)/global/httpsHealthChecks/(?P<name>[^/]+)", "(?P<project>[^/]+)/(?P<name>[^/]+)", "(?P<name>[^/]+)"}, d, config)
|
|
|
|
|
|
|
|
// Replace import id for the resource id
|
|
|
|
id, err := replaceVars(d, config, "{{name}}")
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("Error constructing id: %s", err)
|
|
|
|
}
|
|
|
|
d.SetId(id)
|
|
|
|
|
|
|
|
return []*schema.ResourceData{d}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func flattenComputeHttpsHealthCheckCheckIntervalSec(v interface{}) interface{} {
|
2018-04-24 21:01:53 +00:00
|
|
|
// Handles the string fixed64 format
|
|
|
|
if strVal, ok := v.(string); ok {
|
2018-05-03 22:35:17 +00:00
|
|
|
if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil {
|
2018-04-24 21:01:53 +00:00
|
|
|
return intVal
|
|
|
|
} // let terraform core handle it if we can't convert the string to an int.
|
|
|
|
}
|
2018-03-10 01:14:32 +00:00
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func flattenComputeHttpsHealthCheckCreationTimestamp(v interface{}) interface{} {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func flattenComputeHttpsHealthCheckDescription(v interface{}) interface{} {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func flattenComputeHttpsHealthCheckHealthyThreshold(v interface{}) interface{} {
|
2018-04-24 21:01:53 +00:00
|
|
|
// Handles the string fixed64 format
|
|
|
|
if strVal, ok := v.(string); ok {
|
2018-05-03 22:35:17 +00:00
|
|
|
if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil {
|
2018-04-24 21:01:53 +00:00
|
|
|
return intVal
|
|
|
|
} // let terraform core handle it if we can't convert the string to an int.
|
|
|
|
}
|
2018-03-10 01:14:32 +00:00
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func flattenComputeHttpsHealthCheckHost(v interface{}) interface{} {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func flattenComputeHttpsHealthCheckName(v interface{}) interface{} {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func flattenComputeHttpsHealthCheckPort(v interface{}) interface{} {
|
2018-04-24 21:01:53 +00:00
|
|
|
// Handles the string fixed64 format
|
|
|
|
if strVal, ok := v.(string); ok {
|
2018-05-03 22:35:17 +00:00
|
|
|
if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil {
|
2018-04-24 21:01:53 +00:00
|
|
|
return intVal
|
|
|
|
} // let terraform core handle it if we can't convert the string to an int.
|
|
|
|
}
|
2018-03-10 01:14:32 +00:00
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func flattenComputeHttpsHealthCheckRequestPath(v interface{}) interface{} {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func flattenComputeHttpsHealthCheckTimeoutSec(v interface{}) interface{} {
|
2018-04-24 21:01:53 +00:00
|
|
|
// Handles the string fixed64 format
|
|
|
|
if strVal, ok := v.(string); ok {
|
2018-05-03 22:35:17 +00:00
|
|
|
if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil {
|
2018-04-24 21:01:53 +00:00
|
|
|
return intVal
|
|
|
|
} // let terraform core handle it if we can't convert the string to an int.
|
|
|
|
}
|
2018-03-10 01:14:32 +00:00
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func flattenComputeHttpsHealthCheckUnhealthyThreshold(v interface{}) interface{} {
|
2018-04-24 21:01:53 +00:00
|
|
|
// Handles the string fixed64 format
|
|
|
|
if strVal, ok := v.(string); ok {
|
2018-05-03 22:35:17 +00:00
|
|
|
if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil {
|
2018-04-24 21:01:53 +00:00
|
|
|
return intVal
|
|
|
|
} // let terraform core handle it if we can't convert the string to an int.
|
|
|
|
}
|
2018-03-10 01:14:32 +00:00
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2018-04-23 23:19:26 +00:00
|
|
|
func expandComputeHttpsHealthCheckCheckIntervalSec(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
|
|
|
return v, nil
|
2018-03-10 01:14:32 +00:00
|
|
|
}
|
|
|
|
|
2018-04-23 23:19:26 +00:00
|
|
|
func expandComputeHttpsHealthCheckDescription(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
|
|
|
return v, nil
|
2018-03-10 01:14:32 +00:00
|
|
|
}
|
|
|
|
|
2018-04-23 23:19:26 +00:00
|
|
|
func expandComputeHttpsHealthCheckHealthyThreshold(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
|
|
|
return v, nil
|
2018-03-10 01:14:32 +00:00
|
|
|
}
|
|
|
|
|
2018-04-23 23:19:26 +00:00
|
|
|
func expandComputeHttpsHealthCheckHost(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
|
|
|
return v, nil
|
2018-03-10 01:14:32 +00:00
|
|
|
}
|
|
|
|
|
2018-04-23 23:19:26 +00:00
|
|
|
func expandComputeHttpsHealthCheckName(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
|
|
|
return v, nil
|
2018-03-10 01:14:32 +00:00
|
|
|
}
|
|
|
|
|
2018-04-23 23:19:26 +00:00
|
|
|
func expandComputeHttpsHealthCheckPort(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
|
|
|
return v, nil
|
2018-03-10 01:14:32 +00:00
|
|
|
}
|
|
|
|
|
2018-04-23 23:19:26 +00:00
|
|
|
func expandComputeHttpsHealthCheckRequestPath(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
|
|
|
return v, nil
|
2018-03-10 01:14:32 +00:00
|
|
|
}
|
|
|
|
|
2018-04-23 23:19:26 +00:00
|
|
|
func expandComputeHttpsHealthCheckTimeoutSec(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
|
|
|
return v, nil
|
2018-03-10 01:14:32 +00:00
|
|
|
}
|
|
|
|
|
2018-04-23 23:19:26 +00:00
|
|
|
func expandComputeHttpsHealthCheckUnhealthyThreshold(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
|
|
|
return v, nil
|
2018-03-10 01:14:32 +00:00
|
|
|
}
|