Interview Prep/Terraform/Plan Errors and Unexpected Replacements

`Error: Invalid function argument` — `no file exists at "./scripts/bootstrap.sh"; this function works only with files that are distributed as part of the configuration source code`.

BeginnerTroubleshootingPlan Errors and Unexpected Replacements
Answer

Likely causes → Paths are relative to the working directory, not the module. Inside a module, ./scripts/... points to the root's folder.

Diagnose → Check where the file lives and where terraform runs.

Fix → file("${path.module}/scripts/bootstrap.sh") or templatefile("${path.module}/templates/user_data.sh.tftpl", {...}).

Prevent → Always prefix file paths with path.module in modules.

All Terraform questions

More on Plan Errors and Unexpected Replacements