From a22891deba1379fcc4849abc96344680185c417a Mon Sep 17 00:00:00 2001 From: Bodo Petermann Date: Thu, 4 Jul 2019 17:11:19 +0200 Subject: [PATCH] Fixes crash #21896 Fix for a crash during terraform plan: If there is a multi-instance resource (count > 1) where one of the instances was deleted in the deployment but was still present in the terraform state, getResourceInstancesAll crashed. Check not only for rs.Instances[key] to exist, but also to have a valid Current pointer. --- terraform/evaluate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/evaluate.go b/terraform/evaluate.go index ab65d475b..11a0dac8a 100644 --- a/terraform/evaluate.go +++ b/terraform/evaluate.go @@ -696,7 +696,7 @@ func (d *evaluationStateData) getResourceInstancesAll(addr addrs.Resource, rng t ty := schema.ImpliedType() key := addrs.IntKey(i) is, exists := rs.Instances[key] - if exists { + if exists && is.Current != nil { instAddr := addr.Instance(key).Absolute(d.ModulePath) // Prefer pending value in plan if present. See getResourceInstanceSingle