-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* mark field as updatable Co-authored-by: upodroid <[email protected]> * add google hc ds Co-authored-by: upodroid <[email protected]>
- Loading branch information
Showing
5 changed files
with
117 additions
and
19 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
mmv1/third_party/terraform/data_sources/data_source_compute_health_check.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package google | ||
|
||
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
|
||
func dataSourceGoogleComputeHealthCheck() *schema.Resource { | ||
// Generate datasource schema from resource | ||
dsSchema := datasourceSchemaFromResourceSchema(resourceComputeHealthCheck().Schema) | ||
|
||
// Set 'Required' schema elements | ||
addRequiredFieldsToSchema(dsSchema, "name") | ||
|
||
// Set 'Optional' schema elements | ||
addOptionalFieldsToSchema(dsSchema, "project") | ||
|
||
return &schema.Resource{ | ||
Read: dataSourceGoogleComputeHealthCheckRead, | ||
Schema: dsSchema, | ||
} | ||
} | ||
|
||
func dataSourceGoogleComputeHealthCheckRead(d *schema.ResourceData, meta interface{}) error { | ||
id, err := replaceVars(d, meta.(*Config), "projects/{{project}}/global/healthChecks/{{name}}") | ||
if err != nil { | ||
return err | ||
} | ||
d.SetId(id) | ||
|
||
return resourceComputeHealthCheckRead(d, meta) | ||
} |
51 changes: 51 additions & 0 deletions
51
mmv1/third_party/terraform/tests/data_source_compute_health_check_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccComputeHealthCheckDatasource_basic(t *testing.T) { | ||
t.Parallel() | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccComputeHealthCheckDatasourceConfig(randString(t, 10)), | ||
Check: resource.ComposeTestCheckFunc( | ||
checkDataSourceStateMatchesResourceState("data.google_compute_health_check.hc", "google_compute_health_check.hc"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccComputeHealthCheckDatasourceConfig(suffix string) string { | ||
return fmt.Sprintf(` | ||
resource "google_compute_health_check" "hc" { | ||
name = "tf-test-%s" | ||
description = "Health check via tcp" | ||
timeout_sec = 1 | ||
check_interval_sec = 1 | ||
healthy_threshold = 4 | ||
unhealthy_threshold = 5 | ||
tcp_health_check { | ||
port_name = "health-check-port" | ||
port_specification = "USE_NAMED_PORT" | ||
request = "ARE YOU HEALTHY?" | ||
proxy_header = "NONE" | ||
response = "I AM HEALTHY" | ||
} | ||
} | ||
data "google_compute_health_check" "hc" { | ||
name = google_compute_health_check.hc.name | ||
} | ||
`, suffix) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
mmv1/third_party/terraform/website/docs/d/compute_health_check.html.markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
subcategory: "Compute Engine" | ||
layout: "google" | ||
page_title: "Google: google_compute_health_check" | ||
sidebar_current: "docs-google-datasource-compute-health-check" | ||
description: |- | ||
Get information about a HealthCheck. | ||
--- | ||
|
||
# google\_compute\_health\_check | ||
|
||
Get information about a HealthCheck. | ||
|
||
## Example Usage | ||
|
||
```tf | ||
data "google_compute_health_check" "health_chceck" { | ||
name = "my-hc" | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `name` - (Required) Name of the resource. | ||
|
||
- - - | ||
|
||
* `project` - (Optional) The ID of the project in which the resource belongs. If it | ||
is not provided, the provider project is used. | ||
|
||
## Attributes Reference | ||
|
||
See [google_compute_health_check](https://www.terraform.io/docs/providers/google/r/compute_health_check.html) resource for details of the available attributes. |