backend/local: decode variables with cty.DynamicPseudoType

Variables values are marshalled with an explicit type of
cty.DynamicPseudoType, but were being decoded using `Implied Type` to
try and guess the type. This was causing errors because `Implied Type`
does not expect to find a late-bound value.
This commit is contained in:
Kristin Laemmert 2018-11-30 15:15:28 -08:00
parent 3dacdba678
commit 67aa944166
1 changed files with 2 additions and 10 deletions

View File

@ -13,6 +13,7 @@ import (
"github.com/hashicorp/terraform/states/statemgr" "github.com/hashicorp/terraform/states/statemgr"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform/tfdiags" "github.com/hashicorp/terraform/tfdiags"
"github.com/zclconf/go-cty/cty"
) )
// backend.Local implementation. // backend.Local implementation.
@ -219,16 +220,7 @@ func (b *Local) contextFromPlanFile(pf *planfile.Reader, opts terraform.ContextO
variables := terraform.InputValues{} variables := terraform.InputValues{}
for name, dyVal := range plan.VariableValues { for name, dyVal := range plan.VariableValues {
ty, err := dyVal.ImpliedType() val, err := dyVal.Decode(cty.DynamicPseudoType)
if err != nil {
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
errSummary,
fmt.Sprintf("Invalid value for variable %q recorded in plan file: %s.", name, err),
))
continue
}
val, err := dyVal.Decode(ty)
if err != nil { if err != nil {
diags = diags.Append(tfdiags.Sourceless( diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error, tfdiags.Error,