diff --git a/google/import_compute_https_health_check_test.go b/google/import_compute_https_health_check_test.go new file mode 100644 index 00000000000..fb212b89d7b --- /dev/null +++ b/google/import_compute_https_health_check_test.go @@ -0,0 +1,28 @@ +package google + +import ( + "fmt" + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" + "testing" +) + +func TestAccComputeHttpsHealthCheck_importBasic(t *testing.T) { + hhckName := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckComputeHttpsHealthCheckDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccComputeHttpsHealthCheck_basic(hhckName), + }, + resource.TestStep{ + ResourceName: "google_compute_https_health_check.foobar", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} diff --git a/google/resource_compute_https_health_check.go b/google/resource_compute_https_health_check.go index 769606268df..4381033ad05 100644 --- a/google/resource_compute_https_health_check.go +++ b/google/resource_compute_https_health_check.go @@ -14,6 +14,9 @@ func resourceComputeHttpsHealthCheck() *schema.Resource { Read: resourceComputeHttpsHealthCheckRead, Delete: resourceComputeHttpsHealthCheckDelete, Update: resourceComputeHttpsHealthCheckUpdate, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -208,10 +211,12 @@ func resourceComputeHttpsHealthCheckRead(d *schema.ResourceData, meta interface{ return handleNotFoundError(err, d, fmt.Sprintf("HTTPS Health Check %q", d.Get("name").(string))) } + d.Set("name", hchk.Name) + d.Set("description", hchk.Description) 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) diff --git a/website/docs/r/compute_https_health_check.html.markdown b/website/docs/r/compute_https_health_check.html.markdown index 79bb102ce82..64abf5ecd52 100644 --- a/website/docs/r/compute_https_health_check.html.markdown +++ b/website/docs/r/compute_https_health_check.html.markdown @@ -61,3 +61,11 @@ The following arguments are supported: The following attributes are exported: * `self_link` - The URL of the created resource. + +## Import + +HTTPS health checks can be imported using the `name`, e.g. + +``` +$ terraform import google_compute_https_health_check.default test +```