Why plan fails on data.local_file?

Hello,

i’m trying to use data resource to read local file, which exists.
And i need this data resource to detect changes, if there are, as later some resources will be recreated if file updated.

so i wrote this block:

data "local_file" "openbao_csr_bash" {
  filename = "${path.module}/files/openbao.csr.bash"
}

and on first iteration all worked as expected, i’ve managed to get content_md5 and proceed with other resources.
But when i repeat terraform plan after first apply - it dropps error:

Planning failed. Terraform encountered an error while generating this plan.

Error: no change found for data.local_file.openbao_csr_bash in the root module

and yes, it is expected, that there are no changes.
and it is expected to get info about that file and that’s it.

do you know why it is like that? is it bug?

terraform version 1.10

Hi @iaroslav-nakonechnik,

That error is coming from evaluating replace_triggered_by, so it is technically a bug, but the bug is that you were allowed to add that reference in the first place!

Pointing replace_triggered_by at a data resource wouldn’t do anything, because data sources don’t ever plan any changes. That needs a warning, or at least a better error message to point out what exactly is causing the failure.

1 Like

thank you,
yes, you were right, and it was due to replace_triggered_by.