Courseiva
Use Terraform outside the core workfloweasyMultiple ChoiceObjective-mapped

TF-004 Use Terraform outside the core workflow Practice Question

A developer wants to use Terraform in a CI pipeline where the pipeline runs on pull requests. They need to preview infrastructure changes without applying them. Which command should be used?

⚠ Common exam trap

HashiCorp often tests the distinction between validation and planning, so the trap here is that candidates confuse `terraform validate` (syntax check) with `terraform plan` (infrastructure preview), assuming validation alone is sufficient to preview changes.

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

terraform plan

`terraform plan` creates an execution plan that shows what actions Terraform will take to change infrastructure to match the configuration, without actually applying any changes. This is the standard command for previewing infrastructure changes in a CI pipeline triggered by pull requests, enabling developers to review proposed modifications before merging.

Answer analysis

Option-by-option breakdown

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

  • terraform plan

    Why this is correct

    The `terraform plan` command generates an execution plan, detailing the actions Terraform will perform to reach the desired state defined in the configuration files. It compares the current state (from the state file) with the desired state (from the configuration) and the actual infrastructure, providing a preview of all proposed infrastructure changes (creations, updates, or destructions) without actually making them. This makes it ideal for CI/CD pipelines to review changes before approval.

  • terraform validate

    Why it's wrong here

    The `terraform validate` command checks the syntax and internal consistency of the Terraform configuration files in the current working directory. It ensures that the configuration is syntactically valid and internally consistent, verifying attribute names, value types, and module configurations. However, it does not interact with remote state or actual cloud providers, nor does it determine the operational impact of the configuration on existing infrastructure.

  • terraform init

    Why it's wrong here

    The `terraform init` command initializes a working directory containing Terraform configuration files. This crucial step downloads necessary provider plugins, sets up backend configuration for state management, and initializes modules. While essential for preparing the environment, `init` does not perform any infrastructure provisioning or even preview changes; it merely prepares Terraform to interact with the chosen providers and state backend.

  • terraform apply

    Why it's wrong here

    The `terraform apply` command executes the actions proposed in a Terraform execution plan, either generated by a prior `terraform plan -out=file` command or interactively confirmed. This command is responsible for provisioning, updating, or destroying real-world infrastructure resources in the target cloud or service provider. Running `apply` directly in a CI pipeline without a preceding `plan` for review bypasses the critical verification step, making it unsuitable for the initial review stage.

About these practice questions

This TF-004 question is part of Courseiva's 428-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. 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.