Error: No configuration files: "Apply requires configuration to be present"
Fixes Terraform's "Error: No configuration files ... Apply requires configuration to be present", which means you ran terraform in a directory with no .tf files. Use when any command fails immediately with this message. cd into the config directory; not for backend or provider errors.
TL;DR
You ran Terraform in a directory that has no .tf files. Nothing is broken; you are just in the wrong folder. cd into the directory that holds your configuration and run the command again.
The error
Error: No configuration files
Apply requires configuration to be present.Steps to fix
Check where you are:
pwdandls *.tf.- Expected: no
.tffiles listed, confirming the diagnosis.
- Expected: no
Move to the configuration directory:
cd terraform(use your actual config path)
- Expected:
ls *.tfnow lists your configuration files.
- Expected:
Re-run the command (
terraform plan,terraform apply, ...).- Expected: Terraform loads the configuration instead of erroring.
When to use this
- Any Terraform command fails instantly with
No configuration files, typically after cloning a repo, in CI with a wrongworking-directory, or in a monorepo where the config lives in a subfolder.
When NOT to use this
Backend initialization requiredmeans config was found but init is missing. In CI, prefer setting the job's working directory overcdin scripts.
Compatibility
- All Terraform versions; the check is unchanged.
Root cause
Terraform only reads configuration from the current working directory (plus -chdir). An empty directory, the repo root of a monorepo, or a CI checkout at the wrong path contains no .tf files, so there is nothing to plan or apply.
Edge cases
- Hidden gotcha:
.tffiles that are all commented out still count as present; this error is strictly about missing files. terraform -chdir=path planlets you stay put and point at the config directory.- In CI, a stale
working-directoryafter a repo restructure is the usual culprit; fix the workflow, not the repo.