"bytes"
"fmt"
"log"
- "reflect"
"strings"
"github.com/hashicorp/hcl2/hcl"
// Should be caught during validation, so we don't bother with a pretty error here
return nil, fmt.Errorf("provider does not support resource type %q", n.Addr.Resource.Type)
}
- keyData := EvalDataForInstanceKey(n.Addr.Key)
+ forEach, _ := evaluateResourceForEachExpression(n.Config.ForEach, ctx)
+ keyData := EvalDataForInstanceKey(n.Addr.Key, forEach)
configVal, _, configDiags := ctx.EvaluateBlock(config.Config, schema, nil, keyData)
diags = diags.Append(configDiags)
if configDiags.HasErrors() {
}
}
+ log.Printf("[TRACE] Re-validating config for %q", n.Addr.Absolute(ctx.Path()))
+ // Allow the provider to validate the final set of values.
+ // The config was statically validated early on, but there may have been
+ // unknown values which the provider could not validate at the time.
+ validateResp := provider.ValidateResourceTypeConfig(
+ providers.ValidateResourceTypeConfigRequest{
+ TypeName: n.Addr.Resource.Type,
+ Config: configVal,
+ },
+ )
+ if validateResp.Diagnostics.HasErrors() {
+ return nil, validateResp.Diagnostics.InConfigBody(config.Config).Err()
+ }
+
// The provider gets an opportunity to customize the proposed new value,
// which in turn produces the _planned_ new value.
resp := provider.PlanResourceChange(providers.PlanResourceChangeRequest{
// must _also_ record the returned change in the active plan,
// which the expression evaluator will use in preference to this
// incomplete value recorded in the state.
- Status: states.ObjectPlanned,
- Value: plannedNewVal,
+ Status: states.ObjectPlanned,
+ Value: plannedNewVal,
+ Private: plannedPrivate,
}
}
// away any deeper values we already produced at that point.
var ignoreTraversal hcl.Traversal
for i, candidate := range ignoreChangesPath {
- if reflect.DeepEqual(path, candidate) {
+ if path.Equals(candidate) {
ignoreTraversal = ignoreChanges[i]
}
}
Before: state.Value,
After: cty.NullVal(cty.DynamicPseudoType),
},
+ Private: state.Private,
ProviderAddr: n.ProviderAddr,
}