diff --git a/internal/resources/syntheticmonitoring/resource_check.go b/internal/resources/syntheticmonitoring/resource_check.go index f987822b7..053b01626 100644 --- a/internal/resources/syntheticmonitoring/resource_check.go +++ b/internal/resources/syntheticmonitoring/resource_check.go @@ -1589,7 +1589,10 @@ func resourceCheckCustomizeDiff(ctx context.Context, diff *schema.ResourceDiff, if len(settingsList) == 0 { return fmt.Errorf("at least one check setting must be defined") } - settings := settingsList[0].(map[string]interface{}) + settings, ok := settingsList[0].(map[string]interface{}) + if !ok { + return fmt.Errorf("at least one check setting must be defined") + } count := 0 for k := range syntheticMonitoringCheckSettings.Schema { diff --git a/internal/resources/syntheticmonitoring/resource_check_test.go b/internal/resources/syntheticmonitoring/resource_check_test.go index 3dabbe7e1..c0a186b10 100644 --- a/internal/resources/syntheticmonitoring/resource_check_test.go +++ b/internal/resources/syntheticmonitoring/resource_check_test.go @@ -73,6 +73,11 @@ func TestAccResourceCheck_dns(t *testing.T) { resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.dns", "settings.0.dns.0.validate_additional_rrs.0.fail_if_not_matches_regexp.0", ".+-good-stuff*"), ), }, + { + ImportState: true, + ImportStateVerify: true, + ResourceName: "grafana_synthetic_monitoring_check.dns", + }, }, }) } @@ -137,6 +142,11 @@ func TestAccResourceCheck_http(t *testing.T) { resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.http", "settings.0.http.0.fail_if_header_matches_regexp.0.allow_missing", "true"), ), }, + { + ImportState: true, + ImportStateVerify: true, + ResourceName: "grafana_synthetic_monitoring_check.http", + }, }, }) } @@ -182,6 +192,11 @@ func TestAccResourceCheck_ping(t *testing.T) { resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.ping", "settings.0.ping.0.dont_fragment", "true"), ), }, + { + ImportState: true, + ImportStateVerify: true, + ResourceName: "grafana_synthetic_monitoring_check.ping", + }, }, }) } @@ -233,6 +248,11 @@ func TestAccResourceCheck_tcp(t *testing.T) { resource.TestMatchResourceAttr("grafana_synthetic_monitoring_check.tcp", "settings.0.tcp.0.tls_config.0.ca_cert", regexp.MustCompile((`^-{5}BEGIN CERTIFICATE`))), ), }, + { + ImportState: true, + ImportStateVerify: true, + ResourceName: "grafana_synthetic_monitoring_check.tcp", + }, }, }) } @@ -280,6 +300,11 @@ func TestAccResourceCheck_traceroute(t *testing.T) { resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.traceroute", "settings.0.traceroute.0.ptr_lookup", "false"), ), }, + { + ImportState: true, + ImportStateVerify: true, + ResourceName: "grafana_synthetic_monitoring_check.traceroute", + }, }, }) } @@ -365,6 +390,11 @@ func TestAccResourceCheck_multihttp(t *testing.T) { resource.TestCheckResourceAttr("grafana_synthetic_monitoring_check.multihttp", "settings.0.multihttp.0.entries.1.assertions.4.expression", "$.slideshow.slides"), ), }, + { + ImportState: true, + ImportStateVerify: true, + ResourceName: "grafana_synthetic_monitoring_check.multihttp", + }, }, }) }