Skip to content

Commit 2561cd5

Browse files
committed
fix(terraform): ensure ordering rich parameters produces no nil values
1 parent 6715cb6 commit 2561cd5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

provisioner/terraform/resources.go

+16
Original file line numberDiff line numberDiff line change
@@ -694,5 +694,21 @@ func orderedRichParametersResources(tfResourcesRichParameters []*tfjson.StateRes
694694
}
695695
}
696696
}
697+
698+
// There's an edge case possible for us to have a parameter name that isn't
699+
// present in the state, since the ordered names come statically from
700+
// parsing the Terraform file. We need to filter out the nil values if there
701+
// are any present.
702+
if len(tfResourcesRichParameters) != len(orderedNames) {
703+
nonNil := make([]*tfjson.StateResource, 0, len(ordered))
704+
for _, resource := range ordered {
705+
if resource != nil {
706+
nonNil = append(nonNil, resource)
707+
}
708+
}
709+
710+
ordered = nonNil
711+
}
712+
697713
return ordered
698714
}

0 commit comments

Comments
 (0)