A developer runs `terraform apply` and gets the error: 'Error: No configuration files'. What is the most likely cause?
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.
Why this answer
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.
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.
How to eliminate wrong answers
Option B is wrong because a missing state file does not cause the 'No configuration files' error; state files are separate from configuration files and are only required after configuration is loaded. Option C is wrong because permission issues would typically produce a 'permission denied' error, not a missing configuration files error. Option D is wrong because a missing provider plugin would cause a provider-related error during initialization or planning, not a 'No configuration files' error.
Option E is wrong because an incomplete backend configuration would result in a backend initialization error, not a missing configuration files error.