Support import for google_compute_https_health_check (#213)

This commit is contained in:
Vincent Roseberry 2017-07-18 11:35:24 -07:00 committed by Dana Hoffman
parent 236c0f5d24
commit f4db3fd1aa
3 changed files with 42 additions and 1 deletions

View File

@ -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,
},
},
})
}

View File

@ -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)

View File

@ -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
```