I recently wrote a terraform deployment to handle our alert rules and escalation chains (as we have a large amount of them). But i also had to import our current configuration into the terraform state.
I noticed when i imported a escalation chain that terraform would then attempt to redeploy the stage configuration even though it was identical to the terraform template.
Further troubleshooting showed that when the resource was imported that it throws a error when it tries to import destinations.0.stages.0 section. It throws a error and fails to import the stage data into the terraform state
Terraform Debug Log Below
2025-09-25T10:43:10.452+1000 [INFO] Terraform version: 1.13.3
2025-09-25T10:43:10.452+1000 [DEBUG] using github.com/hashicorp/go-tfe v1.74.1
2025-09-25T10:43:10.452+1000 [DEBUG] using github.com/hashicorp/hcl/v2 v2.24.0
2025-09-25T10:43:10.452+1000 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2025-09-25T10:43:10.452+1000 [DEBUG] using github.com/zclconf/go-cty v1.16.3
2025-09-25T10:43:10.452+1000 [INFO] Go runtime version: go1.24.5
2025-09-25T10:43:10.452+1000 [INFO] CLI args: []string{"terraform", "import", "module.alert_rules.logicmonitor_escalation_chain.chains[\"Test escalation chain - terraform import\"]", "13"}
2025-09-25T10:43:10.452+1000 [DEBUG] Attempting to open CLI config file: /Users/neofire/.terraformrc
2025-09-25T10:43:10.453+1000 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2025-09-25T10:43:10.453+1000 [INFO] Loading CLI configuration from /Users/neofire/.terraform.d/credentials.tfrc.json
2025-09-25T10:43:10.463+1000 [DEBUG] checking for credentials in "/Users/neofire/.terraform.d/plugins"
2025-09-25T10:43:10.464+1000 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2025-09-25T10:43:10.464+1000 [DEBUG] will search for provider plugins in /Users/neofire/.terraform.d/plugins
2025-09-25T10:43:10.466+1000 [DEBUG] ignoring non-existing provider search directory /Users/neofire/Library/Application Support/io.terraform/plugins
2025-09-25T10:43:10.466+1000 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2025-09-25T10:43:10.467+1000 [INFO] CLI command args: []string{"import", "module.alert_rules.logicmonitor_escalation_chain.chains[\"Test escalation chain - terraform import\"]", "13"}
2025-09-25T10:43:10.599+1000 [DEBUG] checking for provisioner in "."
2025-09-25T10:43:10.605+1000 [DEBUG] checking for provisioner in "/opt/homebrew/bin"
2025-09-25T10:43:10.605+1000 [DEBUG] checking for provisioner in "/Users/neofire/.terraform.d/plugins"
2025-09-25T10:43:10.611+1000 [DEBUG] Building and walking import graph
2025-09-25T10:43:10.612+1000 [DEBUG] Not attaching any node states: overall state is nil
2025-09-25T10:43:10.612+1000 [DEBUG] No state, no orphan outputs
2025-09-25T10:43:10.615+1000 [DEBUG] ProviderTransformer: "module.alert_rules.data.logicmonitor_escalation_chain.existing_chains (expand)" (*terraform.nodeExpandPlannableResource) needs provider["registry.terraform.io/logicmonitor/logicmonitor"]
2025-09-25T10:43:10.615+1000 [DEBUG] ProviderTransformer: "module.alert_rules.logicmonitor_escalation_chain.chains (expand)" (*terraform.nodeExpandPlannableResource) needs provider["registry.terraform.io/logicmonitor/logicmonitor"]
2025-09-25T10:43:10.615+1000 [DEBUG] ProviderTransformer: "module.alert_rules.logicmonitor_alert_rule.rules (expand)" (*terraform.nodeExpandPlannableResource) needs provider["registry.terraform.io/logicmonitor/logicmonitor"]
2025-09-25T10:43:10.616+1000 [DEBUG] created provider logger: level=debug
2025-09-25T10:43:10.616+1000 [INFO] provider: configuring client automatic mTLS
2025-09-25T10:43:10.624+1000 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/logicmonitor/logicmonitor/2.0.24/darwin_arm64/terraform-provider-logicmonitor_v2.0.24 args=[".terraform/providers/registry.terraform.io/logicmonitor/logicmonitor/2.0.24/darwin_arm64/terraform-provider-logicmonitor_v2.0.24"]
2025-09-25T10:43:10.628+1000 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/logicmonitor/logicmonitor/2.0.24/darwin_arm64/terraform-provider-logicmonitor_v2.0.24 pid=49127
2025-09-25T10:43:10.629+1000 [DEBUG] provider: waiting for RPC address: plugin=.terraform/providers/registry.terraform.io/logicmonitor/logicmonitor/2.0.24/darwin_arm64/terraform-provider-logicmonitor_v2.0.24
2025-09-25T10:43:10.647+1000 [INFO] provider.terraform-provider-logicmonitor_v2.0.24: configuring server automatic mTLS: timestamp="2025-09-25T10:43:10.646+1000"
2025-09-25T10:43:10.654+1000 [DEBUG] provider.terraform-provider-logicmonitor_v2.0.24: plugin address: address=/var/folders/_g/1z4b3py97cz6xk5hwg_q6gfm0000gn/T/plugin130852569 network=unix timestamp="2025-09-25T10:43:10.654+1000"
2025-09-25T10:43:10.654+1000 [DEBUG] provider: using plugin: version=5
2025-09-25T10:43:10.684+1000 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2025-09-25T10:43:10.685+1000 [INFO] provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/logicmonitor/logicmonitor/2.0.24/darwin_arm64/terraform-provider-logicmonitor_v2.0.24 id=49127
2025-09-25T10:43:10.685+1000 [DEBUG] provider: plugin exited
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "module.alert_rules (expand)" references: []
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "module.alert_rules.data.logicmonitor_escalation_chain.existing_chains (expand)" references: [module.alert_rules.var.alert_rules (expand) module.alert_rules.var.alert_rules (validation) module.alert_rules.var.escalation_chains (expand) module.alert_rules.var.escalation_chains (validation)]
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "module.alert_rules.var.escalation_chains (expand)" references: []
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "output.created_alert_rules (expand)" references: [module.alert_rules.output.alert_rules (expand)]
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "module.alert_rules (close)" references: []
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "module.alert_rules.var.alert_rules (expand)" references: []
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "module.alert_rules.var.escalation_chains (validation)" references: []
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "module.alert_rules.logicmonitor_escalation_chain.chains (expand)" references: [module.alert_rules.var.escalation_chains (expand) module.alert_rules.var.escalation_chains (validation)]
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "module.alert_rules.var.alert_rules (validation)" references: []
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "module.alert_rules.output.alert_rules (expand)" references: [module.alert_rules.logicmonitor_alert_rule.rules (expand)]
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "module.alert_rules.output.escalation_chain_ids (expand)" references: [module.alert_rules.logicmonitor_escalation_chain.chains (expand) module.alert_rules.data.logicmonitor_escalation_chain.existing_chains (expand)]
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "module.alert_rules.output.escalation_chains (expand)" references: [module.alert_rules.logicmonitor_escalation_chain.chains (expand)]
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "output.created_escalation_chains (expand)" references: [module.alert_rules.output.escalation_chains (expand)]
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "output.alert_rule_ids (expand)" references: [module.alert_rules.output.alert_rule_ids (expand)]
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/logicmonitor/logicmonitor\"]" references: []
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "module.alert_rules.logicmonitor_alert_rule.rules (expand)" references: [module.alert_rules.logicmonitor_escalation_chain.chains (expand) module.alert_rules.var.alert_rules (expand) module.alert_rules.var.alert_rules (validation) module.alert_rules.var.escalation_chains (expand) module.alert_rules.var.escalation_chains (validation) module.alert_rules.logicmonitor_escalation_chain.chains (expand) module.alert_rules.data.logicmonitor_escalation_chain.existing_chains (expand)]
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "module.alert_rules.output.alert_rule_ids (expand)" references: [module.alert_rules.logicmonitor_alert_rule.rules (expand)]
2025-09-25T10:43:10.685+1000 [DEBUG] ReferenceTransformer: "output.escalation_chain_ids (expand)" references: [module.alert_rules.output.escalation_chain_ids (expand)]
2025-09-25T10:43:10.686+1000 [DEBUG] Starting graph walk: walkImport
2025-09-25T10:43:10.687+1000 [DEBUG] created provider logger: level=debug
2025-09-25T10:43:10.687+1000 [INFO] provider: configuring client automatic mTLS
2025-09-25T10:43:10.690+1000 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/logicmonitor/logicmonitor/2.0.24/darwin_arm64/terraform-provider-logicmonitor_v2.0.24 args=[".terraform/providers/registry.terraform.io/logicmonitor/logicmonitor/2.0.24/darwin_arm64/terraform-provider-logicmonitor_v2.0.24"]
2025-09-25T10:43:10.692+1000 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/logicmonitor/logicmonitor/2.0.24/darwin_arm64/terraform-provider-logicmonitor_v2.0.24 pid=49128
2025-09-25T10:43:10.692+1000 [DEBUG] provider: waiting for RPC address: plugin=.terraform/providers/registry.terraform.io/logicmonitor/logicmonitor/2.0.24/darwin_arm64/terraform-provider-logicmonitor_v2.0.24
2025-09-25T10:43:10.701+1000 [INFO] provider.terraform-provider-logicmonitor_v2.0.24: configuring server automatic mTLS: timestamp="2025-09-25T10:43:10.701+1000"
2025-09-25T10:43:10.708+1000 [DEBUG] provider.terraform-provider-logicmonitor_v2.0.24: plugin address: address=/var/folders/_g/1z4b3py97cz6xk5hwg_q6gfm0000gn/T/plugin3737378218 network=unix timestamp="2025-09-25T10:43:10.708+1000"
2025-09-25T10:43:10.708+1000 [DEBUG] provider: using plugin: version=5
2025-09-25T10:43:10.736+1000 [WARN] ValidateProviderConfig from "provider[\"registry.terraform.io/logicmonitor/logicmonitor\"]" changed the config value, but that value is unused
2025-09-25T10:43:10.736+1000 [DEBUG] ReferenceTransformer: "module.alert_rules.logicmonitor_escalation_chain.chains[\"Test escalation chain - terraform import\"] (import id \"13\")" references: []
module.alert_rules.logicmonitor_escalation_chain.chains["Test escalation chain - terraform import"]: Importing from ID "13"...
2025-09-25T10:43:11.310+1000 [INFO] provider.terraform-provider-logicmonitor_v2.0.24: 2025/09/25 10:43:11 [TRACE] response: [GET /setting/alert/chains/{id}][200] getEscalationChainByIdOK &{CcDestinations:[] Description:Test escalation chain for terraform import Destinations:[0x14000c84360] EnableThrottling:false ID:13 InAlerting:0x14000c80566 Name:0x140008ee510 ThrottlingAlerts:20 ThrottlingPeriod:10}: timestamp="2025-09-25T10:43:11.310+1000"
2025-09-25T10:43:11.310+1000 [INFO] provider.terraform-provider-logicmonitor_v2.0.24: 2025/09/25 10:43:11 [ERROR] setting state: destinations.0.stages.0: '': source data must be an array or slice, got map: timestamp="2025-09-25T10:43:11.310+1000"
module.alert_rules.logicmonitor_escalation_chain.chains["Test escalation chain - terraform import"]: Import prepared!
Prepared logicmonitor_escalation_chain for import
module.alert_rules.logicmonitor_escalation_chain.chains["Test escalation chain - terraform import"]: Refreshing state... [id=13]
2025-09-25T10:43:11.480+1000 [INFO] provider.terraform-provider-logicmonitor_v2.0.24: 2025/09/25 10:43:11 [TRACE] response: [GET /setting/alert/chains/{id}][200] getEscalationChainByIdOK &{CcDestinations:[] Description:Test escalation chain for terraform import Destinations:[0x1400043de30] EnableThrottling:false ID:13 InAlerting:0x1400043a4fe Name:0x14000441910 ThrottlingAlerts:20 ThrottlingPeriod:10}: timestamp="2025-09-25T10:43:11.480+1000"
2025-09-25T10:43:11.480+1000 [INFO] provider.terraform-provider-logicmonitor_v2.0.24: 2025/09/25 10:43:11 [ERROR] setting state: destinations.0.stages.0: '': source data must be an array or slice, got map: timestamp="2025-09-25T10:43:11.480+1000"
2025-09-25T10:43:11.484+1000 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2025-09-25T10:43:11.486+1000 [INFO] provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/logicmonitor/logicmonitor/2.0.24/darwin_arm64/terraform-provider-logicmonitor_v2.0.24 id=49128
2025-09-25T10:43:11.486+1000 [DEBUG] provider: plugin exited
2025-09-25T10:43:11.486+1000 [INFO] Writing state output to:
Specific error that is causing the issue
module.alert_rules.logicmonitor_escalation_chain.chains["Test escalation chain - terraform import"]: Importing from ID "13"...
2025-09-25T10:43:11.310+1000 [INFO] provider.terraform-provider-logicmonitor_v2.0.24: 2025/09/25 10:43:11 [TRACE] response: [GET /setting/alert/chains/{id}][200] getEscalationChainByIdOK &{CcDestinations:[] Description:Test escalation chain for terraform import Destinations:[0x14000c84360] EnableThrottling:false ID:13 InAlerting:0x14000c80566 Name:0x140008ee510 ThrottlingAlerts:20 ThrottlingPeriod:10}: timestamp="2025-09-25T10:43:11.310+1000"
2025-09-25T10:43:11.310+1000 [INFO] provider.terraform-provider-logicmonitor_v2.0.24: 2025/09/25 10:43:11 [ERROR] setting state: destinations.0.stages.0: '': source data must be an array or slice, got map: timestamp="2025-09-25T10:43:11.310+1000"
I recently wrote a terraform deployment to handle our alert rules and escalation chains (as we have a large amount of them). But i also had to import our current configuration into the terraform state.
I noticed when i imported a escalation chain that terraform would then attempt to redeploy the stage configuration even though it was identical to the terraform template.
Further troubleshooting showed that when the resource was imported that it throws a error when it tries to import
destinations.0.stages.0section. It throws a error and fails to import the stage data into the terraform stateTerraform Debug Log Below
Specific error that is causing the issue