Skip to content

Commit

Permalink
Add support for checker_type in uptime_check_config (#5987) (#11686)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed May 11, 2022
1 parent 7c02728 commit a8c4eef
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/5987.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
monitoring: Added `checker_type` field to `google_monitoring_uptime_check_config` resource
```
4 changes: 2 additions & 2 deletions google/resource_clouddeploy_target_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ resource "google_clouddeploy_target" "primary" {
}
labels = {
my_third_label = "example-label-3"
my_second_label = "updated-example-label-2"
my_third_label = "example-label-3"
}
project = "%{project_name}"
Expand Down
25 changes: 25 additions & 0 deletions google/resource_monitoring_uptime_check_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ func resourceMonitoringUptimeCheckConfig() *schema.Resource {
Required: true,
Description: `The maximum amount of time to wait for the request to complete (must be between 1 and 60 seconds). Accepted formats https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Duration`,
},
"checker_type": {
Type: schema.TypeString,
Computed: true,
Optional: true,
ForceNew: true,
ValidateFunc: validateEnum([]string{"STATIC_IP_CHECKERS", "VPC_CHECKERS", ""}),
Description: `The checker type to use for the check. If the monitored resource type is servicedirectory_service, checkerType must be set to VPC_CHECKERS. Possible values: ["STATIC_IP_CHECKERS", "VPC_CHECKERS"]`,
},
"content_matchers": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -312,6 +320,12 @@ func resourceMonitoringUptimeCheckConfigCreate(d *schema.ResourceData, meta inte
} else if v, ok := d.GetOkExists("selected_regions"); !isEmptyValue(reflect.ValueOf(selectedRegionsProp)) && (ok || !reflect.DeepEqual(v, selectedRegionsProp)) {
obj["selectedRegions"] = selectedRegionsProp
}
checkerTypeProp, err := expandMonitoringUptimeCheckConfigCheckerType(d.Get("checker_type"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("checker_type"); !isEmptyValue(reflect.ValueOf(checkerTypeProp)) && (ok || !reflect.DeepEqual(v, checkerTypeProp)) {
obj["checkerType"] = checkerTypeProp
}
httpCheckProp, err := expandMonitoringUptimeCheckConfigHttpCheck(d.Get("http_check"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -456,6 +470,9 @@ func resourceMonitoringUptimeCheckConfigRead(d *schema.ResourceData, meta interf
if err := d.Set("selected_regions", flattenMonitoringUptimeCheckConfigSelectedRegions(res["selectedRegions"], d, config)); err != nil {
return fmt.Errorf("Error reading UptimeCheckConfig: %s", err)
}
if err := d.Set("checker_type", flattenMonitoringUptimeCheckConfigCheckerType(res["checkerType"], d, config)); err != nil {
return fmt.Errorf("Error reading UptimeCheckConfig: %s", err)
}
if err := d.Set("http_check", flattenMonitoringUptimeCheckConfigHttpCheck(res["httpCheck"], d, config)); err != nil {
return fmt.Errorf("Error reading UptimeCheckConfig: %s", err)
}
Expand Down Expand Up @@ -694,6 +711,10 @@ func flattenMonitoringUptimeCheckConfigSelectedRegions(v interface{}, d *schema.
return v
}

func flattenMonitoringUptimeCheckConfigCheckerType(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}

func flattenMonitoringUptimeCheckConfigHttpCheck(v interface{}, d *schema.ResourceData, config *Config) interface{} {
if v == nil {
return nil
Expand Down Expand Up @@ -927,6 +948,10 @@ func expandMonitoringUptimeCheckConfigSelectedRegions(v interface{}, d Terraform
return v, nil
}

func expandMonitoringUptimeCheckConfigCheckerType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandMonitoringUptimeCheckConfigHttpCheck(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ resource "google_monitoring_uptime_check_config" "http" {
content_matchers {
content = "example"
}
checker_type = "STATIC_IP_CHECKERS"
}
`, context)
}
Expand Down
7 changes: 7 additions & 0 deletions website/docs/r/monitoring_uptime_check_config.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ resource "google_monitoring_uptime_check_config" "http" {
content_matchers {
content = "example"
}
checker_type = "STATIC_IP_CHECKERS"
}
```
## Example Usage - Uptime Check Config Https
Expand Down Expand Up @@ -150,6 +152,11 @@ The following arguments are supported:
(Optional)
The list of regions from which the check will be run. Some regions contain one location, and others contain more than one. If this field is specified, enough regions to include a minimum of 3 locations must be provided, or an error message is returned. Not specifying this field will result in uptime checks running from all regions.

* `checker_type` -
(Optional)
The checker type to use for the check. If the monitored resource type is servicedirectory_service, checkerType must be set to VPC_CHECKERS.
Possible values are `STATIC_IP_CHECKERS` and `VPC_CHECKERS`.

* `http_check` -
(Optional)
Contains information needed to make an HTTP or HTTPS check.
Expand Down

0 comments on commit a8c4eef

Please sign in to comment.