From 8550bad06b6ee335c4d0702aa93bfe6bcaf1c2f6 Mon Sep 17 00:00:00 2001 From: Noah Webb Date: Thu, 4 Aug 2016 13:53:45 -0400 Subject: [PATCH] provider/google: Support Import of 'google_resource_http_health_check' --- import_compute_http_health_check_test.go | 28 ++++++++++++++++++++++++ resource_compute_http_health_check.go | 9 +++++++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 import_compute_http_health_check_test.go diff --git a/import_compute_http_health_check_test.go b/import_compute_http_health_check_test.go new file mode 100644 index 00000000..02750988 --- /dev/null +++ b/import_compute_http_health_check_test.go @@ -0,0 +1,28 @@ +package google + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccComputeHttpHealthCheck_importBasic(t *testing.T) { + resourceName := "google_compute_http_health_check.foobar" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckComputeHttpHealthCheckDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccComputeHttpHealthCheck_basic, + }, + + resource.TestStep{ + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} diff --git a/resource_compute_http_health_check.go b/resource_compute_http_health_check.go index 70c0146b..0802db8b 100644 --- a/resource_compute_http_health_check.go +++ b/resource_compute_http_health_check.go @@ -15,6 +15,9 @@ func resourceComputeHttpHealthCheck() *schema.Resource { Read: resourceComputeHttpHealthCheckRead, Delete: resourceComputeHttpHealthCheckDelete, Update: resourceComputeHttpHealthCheckUpdate, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -55,6 +58,7 @@ func resourceComputeHttpHealthCheck() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, + Computed: true, }, "request_path": &schema.Schema{ @@ -220,11 +224,14 @@ func resourceComputeHttpHealthCheckRead(d *schema.ResourceData, meta interface{} d.Set("host", hchk.Host) d.Set("request_path", hchk.RequestPath) d.Set("check_interval_sec", hchk.CheckIntervalSec) - d.Set("health_threshold", hchk.HealthyThreshold) + d.Set("healthy_threshold", hchk.HealthyThreshold) d.Set("port", hchk.Port) d.Set("timeout_sec", hchk.TimeoutSec) d.Set("unhealthy_threshold", hchk.UnhealthyThreshold) d.Set("self_link", hchk.SelfLink) + d.Set("name", hchk.Name) + d.Set("description", hchk.Description) + d.Set("project", project) return nil }