Skip to content

Commit

Permalink
Support import for google_compute_https_health_check (hashicorp#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
rosbo authored and danawillow committed Jul 18, 2017
1 parent c7a59d1 commit 37f1ce0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
28 changes: 28 additions & 0 deletions google/import_compute_https_health_check_test.go
Original file line number Diff line number Diff line change
@@ -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,
},
},
})
}
7 changes: 6 additions & 1 deletion google/resource_compute_https_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions website/docs/r/compute_https_health_check.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

0 comments on commit 37f1ce0

Please sign in to comment.