don't expand EachMode from state during validation
Validate should not require state or changes to be present. Break out early when using evaluationStateData during walkValidate before checking state or changes, to prevent errors when indexing resources that haven't been expanded.
This commit is contained in:
parent
c70be3c328
commit
21d06aac41
|
@ -289,6 +289,7 @@ func (ctx *BuiltinEvalContext) EvaluationScope(self addrs.Referenceable, keyData
|
|||
Evaluator: ctx.Evaluator,
|
||||
ModulePath: ctx.PathValue,
|
||||
InstanceKeyData: keyData,
|
||||
Operation: ctx.Evaluator.Operation,
|
||||
}
|
||||
return ctx.Evaluator.Scope(data, self)
|
||||
}
|
||||
|
|
|
@ -91,6 +91,10 @@ type evaluationStateData struct {
|
|||
// since the user specifies in that case which variable name to locally
|
||||
// shadow.)
|
||||
InstanceKeyData InstanceKeyEvalData
|
||||
|
||||
// Operation records the type of walk the evaluationStateData is being used
|
||||
// for.
|
||||
Operation walkOperation
|
||||
}
|
||||
|
||||
// InstanceKeyEvalData is used during evaluation to specify which values,
|
||||
|
@ -506,6 +510,12 @@ func (d *evaluationStateData) GetResourceInstance(addr addrs.ResourceInstance, r
|
|||
return cty.DynamicVal, diags
|
||||
}
|
||||
|
||||
// Break out early during validation, because resource may not be expanded
|
||||
// yet and indexed references may show up as invalid.
|
||||
if d.Operation == walkValidate {
|
||||
return cty.DynamicVal, diags
|
||||
}
|
||||
|
||||
schema := d.getResourceSchema(addr.ContainingResource(), rs.ProviderConfig)
|
||||
|
||||
// If we are able to automatically convert to the "right" type of instance
|
||||
|
|
Loading…
Reference in New Issue