Name string
Sensitive bool
Value *config.RawConfig
+ // ContinueOnErr allows interpolation to fail during Input
+ ContinueOnErr bool
}
// TODO: test
func (n *EvalWriteOutput) Eval(ctx EvalContext) (interface{}, error) {
+ // This has to run before we have a state lock, since interpolation also
+ // reads the state
cfg, err := ctx.Interpolate(n.Value, nil)
- if err != nil {
- // Log error but continue anyway
- log.Printf("[WARN] Output interpolation %q failed: %s", n.Name, err)
- }
+ // handle the error after we have the module from the state
state, lock := ctx.State()
if state == nil {
// Get a write lock so we can access this instance
lock.Lock()
defer lock.Unlock()
-
// Look for the module state. If we don't have one, create it.
mod := state.ModuleByPath(ctx.Path())
if mod == nil {
mod = state.AddModule(ctx.Path())
}
+ // handling the interpolation error
+ if err != nil {
+ if n.ContinueOnErr || flagWarnOutputErrors {
+ log.Printf("[ERROR] Output interpolation %q failed: %s", n.Name, err)
+ // if we're continuing, make sure the output is included, and
+ // marked as unknown
+ mod.Outputs[n.Name] = &OutputState{
+ Type: "string",
+ Value: config.UnknownVariableValue,
+ }
+ return nil, EvalEarlyExitError{}
+ }
+ return nil, err
+ }
+
// Get the value from the config
var valueRaw interface{} = config.UnknownVariableValue
if cfg != nil {