TA-002-P · Question #80
TA-002-P Question #80: Real Exam Question with Answer & Explanation
The correct answer is C: The Terraform CLI needs you to log into Terraform cloud first. A terraform apply command will fail in a new configuration with a local backend because Terraform needs to first install the necessary provider plugins during the terraform init phase. Without initialization, Terraform cannot interact with the specified infrastructure providers.
Question
You write a new Terraform configuration and immediately run terraform apply in the CLI using the local backend. Why will the apply fail?
Options
- ATerraform needs you to format your code according to best practices first
- BTerraform needs to install the necessary plugins first
- CThe Terraform CLI needs you to log into Terraform cloud first
- DTerraform requires you to manually run terraform plan first
Explanation
A terraform apply command will fail in a new configuration with a local backend because Terraform needs to first install the necessary provider plugins during the terraform init phase. Without initialization, Terraform cannot interact with the specified infrastructure providers.
Common mistakes.
- A. Code formatting (e.g., via
terraform fmt) is for readability and consistency, not a prerequisite forterraform applyto succeed. - C. Logging into Terraform Cloud is only required if using Terraform Cloud as a backend or for remote operations, not for a local backend.
- D. While
terraform planis a good practice to review changes, it is not strictly required beforeterraform apply;applyimplicitly performs a plan.
Concept tested. Terraform initialization and provider plugin installation
Reference. https://developer.hashicorp.com/terraform/cli/commands/init
Topics
Community Discussion
No community discussion yet for this question.