Courseiva
Understand Terraform basicshardMultiple ChoiceObjective-mapped

TF-004 Understand Terraform basics Practice Question

A developer runs `terraform apply` and gets the error: 'Error: No configuration files'. What is the most likely cause?

⚠ Common exam trap

Candidates often confuse the error for a missing configuration file with a missing state file. The error 'No configuration files' is specific to the absence of .tf files, not state files or permissions.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

The working directory does not contain any `.tf` files

The error 'No configuration files' occurs when Terraform cannot find any `.tf` files in the current working directory. Terraform requires at least one configuration file with a `.tf` extension to define resources, data sources, or providers. Without these files, Terraform has no instructions to execute, so it fails immediately during the initialization or planning phase.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • The working directory does not contain any `.tf` files

    Why this is correct

    When `terraform apply` is executed, Terraform expects to find configuration files (ending with `.tf`) in the current working directory. These files define the infrastructure resources, providers, and variables that Terraform needs to manage. Without any `.tf` files, Terraform has no configuration to parse or plan against, leading to an error indicating that no configuration was found or that the directory is empty of Terraform files, preventing any operation.

  • The state file is missing

    Why it's wrong here

    A missing state file (`terraform.tfstate`) would typically result in a specific error message explicitly stating "no state file was found" or "state file not found." While `terraform apply` relies on the state file to understand the current infrastructure, its absence doesn't prevent Terraform from *attempting* to read configuration; it just means there's no known prior state to compare against, leading to a different, more explicit error than a generic "error."

  • The user does not have permissions to read the directory

    Why it's wrong here

    If the user lacks the necessary read permissions for the working directory, Terraform would encounter a "permission denied" error when attempting to access or parse files within that directory. This specific system-level error message clearly indicates an access problem, rather than a generic "error" that might suggest a configuration or operational issue within Terraform itself, allowing for precise troubleshooting.

  • The provider plugin is not installed

    Why it's wrong here

    Provider plugins are downloaded and installed during the `terraform init` phase, which must successfully complete before `terraform apply` can be executed. If a required provider plugin is missing or not installed, the `terraform init` command would fail with an error indicating the inability to find or download the provider, preventing `terraform apply` from even starting its planning or execution phase.

  • The backend configuration is incomplete

    Why it's wrong here

    An incomplete or improperly configured backend, which specifies where Terraform stores its state file, would typically manifest as an error during `terraform init` or `terraform plan`. Terraform validates backend configurations early in its workflow, often before or during the initial state loading or plan generation, resulting in specific backend-related error messages rather than a generic "error" during `apply`.

About these practice questions

One of 428 original TF-004 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This TF-004 practice question is part of Courseiva's free HashiCorp certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the TF-004 exam.