I have been trying to understand why I get a plan to recreate my resources, whenever my Read script fails.
And as far as I understand it, the reason is that the error inside resourceShellScriptRead is not being returned:
func resourceShellScriptRead(d *schema.ResourceData, meta interface{}) error {
err := read(d, meta, []Action{ActionRead})
if err != nil {
_ = d.Set("read_error", err.Error())
} else {
_ = d.Set("read_error", "")
}
// Error could be caused by bugs in the script.
// Give user chance to fix the script or continue to recreate the resource
return nil
}
if v, _ := d.GetChange("read_error"); v != nil {
if e, _ := v.(string); e != "" {
_ = d.ForceNew("read_error") // read error, force recreation
return
}
}
It would be very helpful to me that my CI failed on an error of my Read script during a terraform plan.
I believe there's no way this can happen at the moment. I'd need to add an optional parameter to the provider letting you define if you want to fail on read_error or not. Do you see any other option here?
Hey!
I have been trying to understand why I get a plan to recreate my resources, whenever my Read script fails. And as far as I understand it, the reason is that the error inside resourceShellScriptRead is not being returned:
It's being used in resourceShellScriptCustomizeDiff:
It would be very helpful to me that my CI failed on an error of my Read script during a terraform plan. I believe there's no way this can happen at the moment. I'd need to add an optional parameter to the provider letting you define if you want to fail on read_error or not. Do you see any other option here?