`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.
More on Plan Errors and Unexpected Replacements
`Error: Invalid for_each argument` — `The "for_each" map includes keys derived from resource attributes that cannot be determined until apply`.Intermediate`The given "for_each" argument value is unsuitable: the "for_each" argument must be a map, or set of strings, and you have provided a value of type list of string.`Beginner`Error: Invalid for_each argument` — `Sensitive values, or values derived from sensitive values, cannot be used as for_each arguments.`Intermediate`Error: Invalid count argument` — `The "count" value depends on resource attributes that cannot be determined until apply`.Intermediate`Error: Unsupported attribute` — `This object has no argument, nested block, or exported attribute named "public_ip_address"`.Beginner`Error: Unsupported attribute` on `module.vpc.private_subnets` — `This object does not have an attribute named "private_subnets"`.Beginner