diff --git a/google/resource_monitoring_uptime_check_config.go b/google/resource_monitoring_uptime_check_config.go index 84a1f24131d..f38de357112 100644 --- a/google/resource_monitoring_uptime_check_config.go +++ b/google/resource_monitoring_uptime_check_config.go @@ -111,6 +111,10 @@ func resourceMonitoringUptimeCheckConfig() *schema.Resource { Type: schema.TypeBool, Optional: true, }, + "validate_ssl": { + Type: schema.TypeBool, + Optional: true, + }, }, }, ConflictsWith: []string{"tcp_check"}, @@ -605,6 +609,8 @@ func flattenMonitoringUptimeCheckConfigHttpCheck(v interface{}, d *schema.Resour flattenMonitoringUptimeCheckConfigHttpCheckPath(original["path"], d) transformed["use_ssl"] = flattenMonitoringUptimeCheckConfigHttpCheckUseSsl(original["useSsl"], d) + transformed["validate_ssl"] = + flattenMonitoringUptimeCheckConfigHttpCheckValidateSsl(original["validateSsl"], d) transformed["mask_headers"] = flattenMonitoringUptimeCheckConfigHttpCheckMaskHeaders(original["maskHeaders"], d) return []interface{}{transformed} @@ -654,6 +660,10 @@ func flattenMonitoringUptimeCheckConfigHttpCheckUseSsl(v interface{}, d *schema. return v } +func flattenMonitoringUptimeCheckConfigHttpCheckValidateSsl(v interface{}, d *schema.ResourceData) interface{} { + return v +} + func flattenMonitoringUptimeCheckConfigHttpCheckMaskHeaders(v interface{}, d *schema.ResourceData) interface{} { return v } @@ -814,6 +824,13 @@ func expandMonitoringUptimeCheckConfigHttpCheck(v interface{}, d TerraformResour transformed["useSsl"] = transformedUseSsl } + transformedValidateSsl, err := expandMonitoringUptimeCheckConfigHttpCheckValidateSsl(original["validate_ssl"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedValidateSsl); val.IsValid() && !isEmptyValue(val) { + transformed["validateSsl"] = transformedValidateSsl + } + transformedMaskHeaders, err := expandMonitoringUptimeCheckConfigHttpCheckMaskHeaders(original["mask_headers"], d, config) if err != nil { return nil, err @@ -881,6 +898,10 @@ func expandMonitoringUptimeCheckConfigHttpCheckUseSsl(v interface{}, d Terraform return v, nil } +func expandMonitoringUptimeCheckConfigHttpCheckValidateSsl(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + func expandMonitoringUptimeCheckConfigHttpCheckMaskHeaders(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { return v, nil } diff --git a/google/resource_monitoring_uptime_check_config_generated_test.go b/google/resource_monitoring_uptime_check_config_generated_test.go index fb7c53d2b42..ff0edde105d 100644 --- a/google/resource_monitoring_uptime_check_config_generated_test.go +++ b/google/resource_monitoring_uptime_check_config_generated_test.go @@ -75,6 +75,59 @@ resource "google_monitoring_uptime_check_config" "http" { `, context) } +func TestAccMonitoringUptimeCheckConfig_uptimeCheckConfigHttpsExample(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "project_id": getTestProjectFromEnv(), + "random_suffix": acctest.RandString(10), + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckMonitoringUptimeCheckConfigDestroy, + Steps: []resource.TestStep{ + { + Config: testAccMonitoringUptimeCheckConfig_uptimeCheckConfigHttpsExample(context), + }, + { + ResourceName: "google_monitoring_uptime_check_config.https", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccMonitoringUptimeCheckConfig_uptimeCheckConfigHttpsExample(context map[string]interface{}) string { + return Nprintf(` +resource "google_monitoring_uptime_check_config" "https" { + display_name = "https-uptime-check%{random_suffix}" + timeout = "60s" + + http_check { + path = "/some-path" + port = "443" + use_ssl = true + validate_ssl = true + } + + monitored_resource { + type = "uptime_url" + labels = { + project_id = "%{project_id}" + host = "192.168.1.1" + } + } + + content_matchers { + content = "example" + } +} +`, context) +} + func TestAccMonitoringUptimeCheckConfig_uptimeCheckTcpExample(t *testing.T) { t.Parallel() diff --git a/website/docs/r/monitoring_uptime_check_config.html.markdown b/website/docs/r/monitoring_uptime_check_config.html.markdown index c10fae78e12..6486a4cf11a 100644 --- a/website/docs/r/monitoring_uptime_check_config.html.markdown +++ b/website/docs/r/monitoring_uptime_check_config.html.markdown @@ -62,6 +62,39 @@ resource "google_monitoring_uptime_check_config" "http" { } } ``` +
+## Example Usage - Uptime Check Config Https + + +```hcl +resource "google_monitoring_uptime_check_config" "https" { + display_name = "https-uptime-check" + timeout = "60s" + + http_check { + path = "/some-path" + port = "443" + use_ssl = true + validate_ssl = true + } + + monitored_resource { + type = "uptime_url" + labels = { + project_id = "my-project-name" + host = "192.168.1.1" + } + } + + content_matchers { + content = "example" + } +} +```