From 4196089e55404fd41a58f15f1c0937f81084bd1c Mon Sep 17 00:00:00 2001 From: Sherzod Karimov Date: Fri, 8 Nov 2024 07:35:10 -0500 Subject: [PATCH] fix import --- datadog/resource_datadog_synthetics_test_.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/datadog/resource_datadog_synthetics_test_.go b/datadog/resource_datadog_synthetics_test_.go index 342daeffc..2656f45b6 100644 --- a/datadog/resource_datadog_synthetics_test_.go +++ b/datadog/resource_datadog_synthetics_test_.go @@ -2936,8 +2936,11 @@ func buildTerraformConfigVariables(configVariables []datadogV1.SyntheticsConfigV // If the variable is secure, the example and pattern are not returned by the API, // so we need to keep the values from the terraform config. if v, ok := localVariable["secure"].(bool); ok && v { - localVariable["example"] = oldConfigVariables[i].(map[string]interface{})["example"].(string) - localVariable["pattern"] = oldConfigVariables[i].(map[string]interface{})["pattern"].(string) + // There is no previous state to fallback on during import + if i < len(oldConfigVariables) && oldConfigVariables[i] != nil { + localVariable["example"] = oldConfigVariables[i].(map[string]interface{})["example"].(string) + localVariable["pattern"] = oldConfigVariables[i].(map[string]interface{})["pattern"].(string) + } } else { if v, ok := configVariable.GetExampleOk(); ok { localVariable["example"] = *v