How to fix Error: No configuration files in Terraform

TerraformBEGINNERMEDIUMUpdated Dec 30, 2025· 185 views

The 'No configuration files' error occurs when Terraform cannot find any .tf files in the working directory. This typically happens when you're in the wrong directory, your files lack the correct extension, or the workspace is misconfigured. Navigate to the correct directory containing your Terraform files to resolve it.

Quick fix

Fixes Error: No configuration files

pwd
ls -la
  1. Verify your current directory
  2. Navigate to the Terraform root directory
  3. Check file extensions
  4. Verify Terraform files exist
terraform — error
pwd
ls -la
Error: No configuration files

What this error means

This error means Terraform was invoked in a directory that contains no Terraform configuration files (files with the .tf extension). By default, Terraform includes all *.tf files in the current working directory as part of the root module configuration. When you run commands like `terraform init`, `terraform plan`, or `terraform apply`, Terraform searches the current directory for configuration files. If it finds none, it cannot proceed because there's nothing to plan or apply. This error is straightforward but occurs frequently when working with multiple Terraform projects or when following tutorials that assume a specific directory structure.

Typical symptoms

  • Error appears when running terraform init, terraform plan, or terraform apply
  • Error message includes 'No configuration files. Plan requires configuration to be present'
  • Commands complete successfully in one directory but fail in another
  • Working from a subdirectory instead of the root Terraform directory
  • CI/CD pipelines fail when the working directory isn't set correctly
  • Message suggests: "Planning without a configuration would mark everything for destruction"
  • Recently cloned a repository and running commands from wrong folder

Common causes

  1. Running Terraform commands from the wrong directory (not where .tf files are located)
  2. Terraform files don't have the .tf extension (e.g., named config.txt or main instead of main.tf)
  3. All Terraform files are in a subdirectory but you're running commands from the parent directory
  4. TF_WORKSPACE environment variable is set incorrectly, pointing to a different workspace
  5. In CI/CD environments, the working directory path isn't configured to match the Terraform root module
  6. Module source URLs are incorrect, causing Terraform to look in the wrong location
  7. Files were accidentally deleted or moved from the expected directory

How to fix "Error: No configuration files"

1Verify your current directory

Check where you are in the filesystem and list the contents:

bash
pwd
ls -la

Look for files ending in .tf. If you see nothing or only other files (like .json or .yaml), you're likely in the wrong directory.

2Navigate to the Terraform root directory

Change to the directory containing your Terraform configuration files:

bash
cd /path/to/your/terraform
ls *.tf

You should see at least one file with a .tf extension (commonly main.tf, variables.tf, or outputs.tf). If you still see nothing, your files may be in a subdirectory—keep exploring.

3Check file extensions

Terraform only recognizes files ending in .tf. If you have configuration files with different extensions, rename them:

bash
# Wrong - these won't be recognized
ls
# main, config.txt, terraform.yml

# Right - these will be recognized
mv main main.tf
mv config.txt config.tf

All files in the directory ending in .tf will be loaded, regardless of name. You can organize them as main.tf, variables.tf, outputs.tf, etc.

4Verify Terraform files exist

List all .tf files in your current directory and subdirectories:

bash
find . -name "*.tf" -type f

If you find files in a subdirectory, either:
- Move to that subdirectory before running Terraform, or
- Use the -chdir option to specify the directory:

bash
terraform -chdir=./terraform init
terraform -chdir=./terraform plan
5Initialize Terraform in the correct directory

Once you're in the right directory with .tf files present, initialize Terraform:

bash
cd /path/to/your/terraform
terraform init

You should see output indicating providers are being installed. If you still get the error, double-check that at least one .tf file exists in the current directory.

6Fix CI/CD working directory

For GitHub Actions:

yaml
- name: Terraform Init
  working-directory: ./terraform
  run: terraform init

For GitLab CI:

yaml
terraform-plan:
  script:
    - cd terraform
    - terraform init
    - terraform plan

For other CI systems, ensure the working directory is set to the folder containing your .tf files before running any Terraform commands.

7Check for workspace issues

If you have set the TF_WORKSPACE environment variable, verify it's pointing to a valid workspace:

bash
echo $TF_WORKSPACE
unset TF_WORKSPACE
terraform init

Try unsetting the workspace variable and reinitializing. If that works, your workspace configuration was incorrect.

Advanced notes

When Terraform is initialized with a remote backend (like Terraform Cloud or S3), it stores state remotely but still requires local .tf files to function. The "No configuration files" error will occur even with a properly configured backend if .tf files are missing locally.

For monorepo setups where you have multiple Terraform configurations in different directories, consider using a wrapper script or Makefile to ensure you're always running Terraform from the correct directory:

bash
#!/bin/bash
cd terraform/$(echo $1 | cut -d/ -f1)
terraform $@

In CI/CD pipelines, use terraform -chdir instead of cd commands to avoid directory context issues that might affect subsequent commands or steps. This makes your pipeline more explicit and maintainable.

Frequently asked questions

What does "Error: No configuration files" mean?
tf extension). tf files in the current working directory as part of the root module configuration. When you run commands like terraform init, terraform plan, or terraform apply, Terraform searches the current directory for configuration files.
How do I fix "Error: No configuration files"?
The 'No configuration files' error occurs when Terraform cannot find any .tf files in the working directory. This typically happens when you're in the wrong directory, your files lack the correct extension, or the workspace is misconfigured. Navigate to the correct directory containing your Terraform files to resolve it.
What causes "Error: No configuration files"?
Running Terraform commands from the wrong directory (not where .tf files are located) Terraform files don't have the .tf extension (e.g., named config.txt or main instead of main.tf) All Terraform files are in a subdirectory but you're running commands from the parent directory
Is the "Error: No configuration files" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading