Skip to content

Commit 3fb6287

Browse files
committed
provider/google: Support Import of 'google_resource_http_health_check'
1 parent 3fc1199 commit 3fb6287

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package google
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform/helper/resource"
7+
)
8+
9+
func TestAccComputeHttpHealthCheck_importBasic(t *testing.T) {
10+
resourceName := "google_compute_http_health_check.foobar"
11+
12+
resource.Test(t, resource.TestCase{
13+
PreCheck: func() { testAccPreCheck(t) },
14+
Providers: testAccProviders,
15+
CheckDestroy: testAccCheckComputeHttpHealthCheckDestroy,
16+
Steps: []resource.TestStep{
17+
resource.TestStep{
18+
Config: testAccComputeHttpHealthCheck_basic,
19+
},
20+
21+
resource.TestStep{
22+
ResourceName: resourceName,
23+
ImportState: true,
24+
ImportStateVerify: true,
25+
},
26+
},
27+
})
28+
}

builtin/providers/google/resource_compute_http_health_check.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ func resourceComputeHttpHealthCheck() *schema.Resource {
1515
Read: resourceComputeHttpHealthCheckRead,
1616
Delete: resourceComputeHttpHealthCheckDelete,
1717
Update: resourceComputeHttpHealthCheckUpdate,
18+
Importer: &schema.ResourceImporter{
19+
State: schema.ImportStatePassthrough,
20+
},
1821

1922
Schema: map[string]*schema.Schema{
2023
"name": &schema.Schema{
@@ -55,6 +58,7 @@ func resourceComputeHttpHealthCheck() *schema.Resource {
5558
Type: schema.TypeString,
5659
Optional: true,
5760
ForceNew: true,
61+
Computed: true,
5862
},
5963

6064
"request_path": &schema.Schema{
@@ -220,11 +224,14 @@ func resourceComputeHttpHealthCheckRead(d *schema.ResourceData, meta interface{}
220224
d.Set("host", hchk.Host)
221225
d.Set("request_path", hchk.RequestPath)
222226
d.Set("check_interval_sec", hchk.CheckIntervalSec)
223-
d.Set("health_threshold", hchk.HealthyThreshold)
227+
d.Set("healthy_threshold", hchk.HealthyThreshold)
224228
d.Set("port", hchk.Port)
225229
d.Set("timeout_sec", hchk.TimeoutSec)
226230
d.Set("unhealthy_threshold", hchk.UnhealthyThreshold)
227231
d.Set("self_link", hchk.SelfLink)
232+
d.Set("name", hchk.Name)
233+
d.Set("description", hchk.Description)
234+
d.Set("project", project)
228235

229236
return nil
230237
}

0 commit comments

Comments
 (0)