Describe the Terraform workflow
Write, plan, apply: the core loop
Say you need to add one server to an environment Terraform already manages. You open the configuration, add a few lines that describe the server, run terraform plan to see exactly what will change, and then run terraform apply to carry it out. Those three moves, in that order, are the whole core Terraform workflow: Write, Plan, and Apply[1].
Write: author the configuration
In the Write stage you author infrastructure as code in the HashiCorp Configuration Language (HCL), editing .tf files much as you would edit application source. While you iterate, running terraform plan gives quick feedback on whether the configuration expresses what you intend. The Write stage produces the durable artifact the rest of the workflow depends on: a text description of the infrastructure you want to exist.
Plan: preview without changing anything
Plan is the safety stage. When you run terraform plan, Terraform reads the current state of already-existing remote objects, compares the current configuration to the prior state, and proposes a set of change actions[2] that would bring the real infrastructure in line with the configuration. The property that makes this safe is that the plan command alone does not actually carry out the proposed changes[2]. It is read-only: it never creates, updates, or destroys a real object, so you can run it as often as you want while you check your work.
Apply: enact the approved plan
Apply is the only stage that changes real infrastructure. The terraform apply command executes the operations proposed in a Terraform plan[3]. When you run terraform apply without handing it a saved plan file, Terraform creates a new execution plan as if you had run terraform plan, prompts you to approve that plan, and then performs the indicated operations[3]. That approval prompt is the default gate between preview and change. You can skip it with -auto-approve, but the rule holds either way: only Apply provisions, updates, or destroys resources.
One command sits outside this loop. On a new or freshly cloned directory you first run terraform init, which prepares the working directory by installing the providers and modules the configuration needs and configuring its backend. Init is a prerequisite, not one of the three stages, so an answer that lists it alongside Write, Plan, and Apply is wrong. The figure traces the path from that one-time setup through the loop to infrastructure that matches your configuration.
Version control turns the loop into a team workflow
The write, plan, apply loop is the same whether one person runs it or a team does; what changes on a team is that version control coordinates the work. Because a Terraform configuration is human-readable declarative text, it lives in a version control system (VCS) such as Git right alongside the application code it provisions, and every change to it carries an author, a timestamp, and a reviewable diff.
The individual loop
For a single practitioner the process mirrors ordinary application development. You author the configuration in an editor and store it in version control[1], using iterative terraform plan runs for feedback as you write. When the configuration is ready you run terraform apply, review the plan it presents, confirm it, and push your repository. The plan you review at apply time is your last checkpoint before anything changes.
The team loop
A team keeps the same three stages but adds review through the repository. Team members work on separate branches so they do not collide with each other's work[1]. When someone opens a pull request, the plan is surfaced for review so the team can ask questions, evaluate risks, and catch mistakes before any potentially harmful changes are made[1]. After the change merges, the team applies it against the latest state. The diagram follows that path from a branch to an apply on the main branch.
This is why the configuration, and not the state file, is the artifact you commit. State can contain secrets and should be excluded from Git workflows[4], and it is written and maintained by Terraform itself, whereas the configuration is the reviewed source of truth a team collaborates on. Reviewing the plan before apply is what makes the loop reliable: it lets a reviewer catch a mistake before it reaches real infrastructure. It lowers the risk of a bad change; it does not make one impossible, so treat the review as a safeguard, not a guarantee.
The Terraform CLI: structure and per-command help
Every Terraform action you take at the terminal is one CLI (command-line interface) invocation, and they all share a single shape. Knowing that shape tells you where each flag belongs and how to look up any command you are unsure about.
The command pattern
Terraform commands follow one form, terraform [global options] <subcommand> [args], as laid out in the Terraform CLI command documentation[5]. You type the terraform binary, then any global options, then a subcommand such as plan or apply, then that subcommand's own arguments. Order matters: global options come before the subcommand name, and the subcommand's arguments come after it. In terraform -chdir=infra plan -out=tfplan, -chdir=infra is a global option, plan is the subcommand, and -out=tfplan is an argument to plan. The figure labels each part of that example.
Global options
Global options change how Terraform runs regardless of the subcommand. Two to recognize:
| Global option | Effect |
|---|---|
-chdir=DIR | Switches to a different working directory before executing the given subcommand[5], so files Terraform would read or write in the current directory are read or written in DIR instead. |
-version | An alias for the version subcommand[5]; prints the Terraform version. |
-chdir is what you reach for in a continuous integration (CI) job or a wrapper script: instead of changing directory first, you point Terraform at the configuration directory, which keeps the invocation independent of where it is launched.
Getting help for any command
When you do not remember a command's options, ask Terraform. To get help for a specific command, use the -help option with the relevant subcommand[5]; for example, terraform validate -help prints that command's usage and its options. The flag is -help (equivalently terraform -help <subcommand>), not -usage, -info, or -man.
Exam-pattern recognition
TA-004 items on the workflow are short and definitional; they test whether you can name the stages, tell preview from change, and read the shape of a Terraform command. No provider-specific detail is required.
A frequent stem asks which steps make up the core Terraform workflow, or asks you to put them in order. The correct answer is Write, Plan, Apply. The classic distractor slips terraform init into that list; reject it, because init is one-time setup that prepares the working directory, not one of the three core stages.
Another stem probes preview versus change. When a question asks which command previews changes without modifying infrastructure, choose terraform plan; when it asks which command actually provisions, choose terraform apply. A distractor claims terraform plan alters resources, or that terraform apply never needs approval. Both are wrong: plan is read-only, and a plain terraform apply prompts for approval unless you pass -auto-approve.
A version-control stem asks what you commit or how teams collaborate. The right answers involve committing the human-readable configuration to a VCS and reviewing the plan on a pull request before apply. Watch two traps: committing the state file rather than the configuration (state can hold secrets and is not the reviewed artifact), and overclaiming that the review workflow makes a bad apply impossible, when review lowers risk rather than removing it.
A CLI stem shows a command line or asks how to get help. Match the pattern terraform [global options] <subcommand> [args]: global options such as -chdir precede the subcommand. To view a subcommand's options the flag is -help (as in terraform plan -help), not -usage or -man.
The three core-workflow stages
| Aspect | Write | Plan | Apply |
|---|---|---|---|
| What you do | Author HCL configuration | Preview the proposed changes | Enact the approved plan |
| Primary command | Edit files, then fmt and validate | terraform plan | terraform apply |
| Changes real infrastructure? | No | No, read-only preview | Yes: creates, updates, or destroys |
| Approval needed? | Not applicable | No | Yes, unless -auto-approve is set |
| Typical version-control step | Commit to a branch | Review the plan on the pull request | Merge, then apply from the main branch |
Sharp facts the exam loves — give these one last read before exam day.
Cheat sheet
Sharp facts the exam loves — scan these before test day.
- Core workflow is Write, Plan, Apply
The core Terraform workflow has three stages in order: Write (author infrastructure as code), Plan (preview the changes Terraform will make), and Apply (provision the described infrastructure).
Trap Assuming 'init' is one of the three core-workflow stages; init is a prerequisite setup step, not one of the Write/Plan/Apply stages.
6 questions test this
- A colleague sketches Terraform's core workflow on a whiteboard as four repeating phases and asks you to remove the one that is really a one-time prerequisite preparing the working directory rather tha
- A platform engineer who is new to Terraform is documenting the standard end-to-end sequence a single practitioner follows to turn a fresh configuration into running infrastructure. Setting aside one-t
- A team migrating away from manual, click-through cloud provisioning is at the point where an engineer expresses the desired infrastructure in configuration files and commits them to version control, b
- An engineer edits a configuration to increase the size of a compute instance and, before doing anything else, wants a read-only summary of exactly which resources Terraform would add, change, or destr
- An engineer runs the Write → Plan → Apply loop several times a day as the configuration evolves, but notices they seldom need to run `terraform init` again after the first time. Which statement best e
- An organization is deciding whether to keep running Terraform from individual laptops or adopt HCP Terraform for the whole team. A lead argues that the fundamental sequence of stages practitioners fol
- Plan previews, Apply provisions
The Plan stage previews proposed changes without altering any real infrastructure, while the Apply stage carries out the approved plan to create, update, or destroy resources.
Trap Believing terraform plan changes infrastructure; plan is read-only and never modifies remote objects.
6 questions test this
- To guarantee that an automated production run executes only the exact changes a human already reviewed, an engineer saves the output of a plan to a file and later hands that file to apply. What is tru
- During a change-review meeting a teammate worries that running `terraform plan` against the production configuration might accidentally recreate a load balancer that another team depends on. As the pr
- A junior teammate believes `terraform plan` and `terraform apply` are interchangeable because both print a list of proposed changes. You need to correct the single most important behavioral difference
- An engineer edits a configuration to increase the size of a compute instance and, before doing anything else, wants a read-only summary of exactly which resources Terraform would add, change, or destr
- An engineer has already generated an execution plan for a new virtual network, reviewed the output, and is satisfied it matches their intent. They now want the described resources to actually exist in
- An organization's policy forbids any command run during a pull-request check from creating, changing, or deleting cloud resources, yet the check must still show reviewers exactly what merging would ch
- Terraform configuration is VCS-friendly text
Terraform configuration is human-readable declarative text (HCL), so it can be committed to a version control system alongside application code and reviewed with standard tools like Git.
Trap Thinking the state file (rather than the configuration) is the artifact you commit to VCS; state can contain secrets and is generally not committed.
6 questions test this
- A team is deciding what to keep in the Git repository for a Terraform project so that infrastructure changes can be reviewed in pull requests and their history preserved over time. Which of the follow
- Two engineers need to work on the same Terraform configuration while keeping their infrastructure changes coordinated and their state consistent. Which arrangement follows Terraform's recommended prac
- A teammate asks why the team can review Terraform configuration using the same Git tools and pull-request process they already use for application source code. Which property of Terraform configuratio
- A team is writing the `.gitignore` for their Terraform repository so that only the appropriate files are committed. Which of these files should be excluded from version control rather than committed t
- While reviewing a pull request, an engineer notices that a colleague has added the project's `terraform.tfstate` file to the shared Git repository next to the `.tf` files. Why does HashiCorp discourag
- A platform engineer is initializing a Git repository for a new Terraform project so the team can review infrastructure changes through pull requests, the same way they review application code. Which f
- Reviewing the plan before apply improves reliability
Running terraform plan before terraform apply lets a team review proposed changes before they touch real infrastructure, catching mistakes early and improving change reliability.
Trap Overclaiming that this workflow means invalid configurations can 'never' be deployed; review reduces risk but does not make bad applies impossible.
5 questions test this
- In the write-plan-apply workflow, teams treat the plan step as a reliability checkpoint. What is the main way that reviewing the `terraform plan` output before running `terraform apply` improves the r
- During a retrospective, a team member argues that because they always run `terraform plan` and review its output before every `terraform apply`, it is now impossible for a broken or non-compliant conf
- An engineer runs `terraform plan` and reviews a proposed change that would destroy and recreate a production database. Deciding the change is wrong, they close the terminal without ever running `terra
- Before modifying a production environment, an engineer wants the rest of the team to see exactly which resources Terraform will create, update, or destroy and to approve those actions, without any rea
- A team wants every proposed infrastructure change to be reviewed by a second engineer before it is applied. Following HashiCorp's recommended collaboration practice, where in the workflow does that re
- -help prints a subcommand's usage
Appending the -help flag to a subcommand (for example, terraform plan -help) prints that command's usage information and its list of available options.
Trap Guessing -usage, -info, or -man; Terraform uses -help (also available as terraform -help ).
20 questions test this
- An engineer opening an interactive session wants to first review the options that the `terraform console` subcommand accepts, printed to the terminal. Which flag do they append to the subcommand to di
- Reviewing formatting options, an engineer half-remembers that Terraform prints a command's options with a flag but blanks on its exact name, and types `terraform fmt -usage`. Which statement correctly
- A platform engineer wants a single, reliable way to look up the accepted options for many different Terraform subcommands, including less common ones such as `terraform providers`, `terraform get`, an
- An engineer wants to print the usage information and the full set of options that the `terraform output` subcommand accepts, without reading any actual output values from state. Following Terraform's
- An engineer types `terraform show -help` in a working directory that already has state, expecting to review the command before using it. Given that `terraform show` normally displays the current state
- An engineer types `terraform apply -help` in a working directory that manages live infrastructure, unsure whether the `-help` flag will still let the apply proceed and begin creating or modifying real
- While reading the `Global options` section printed by `terraform -help`, an engineer notices the entry described as showing this help output, or the help for a specified subcommand. Acting on that des
- A platform engineer is scanning the list of Terraform's global options and needs the one that will display the usage information and accepted options for a particular subcommand such as `plan`. Which
- An engineer runs `terraform plan -help` and wants to predict what the top of the output looks like before reading it. Which description most accurately reflects what the `-help` option prints for the
- Working on a build agent with no internet access, an engineer cannot reach the Terraform documentation website but still needs to see the options that the `terraform login` subcommand accepts. How can
- During a review, an engineer runs `terraform validate -help` and needs to describe what appears on screen to a teammate. Which description correctly characterizes the output that the `-help` option pr
- A platform engineer is preparing to run `terraform destroy` against a scratch working directory and, before doing so, wants to print the destroy command's usage line and the complete list of options i
- An engineer wants to review the accepted options and usage for the `state list` operation, which is one of the subcommands grouped under `terraform state`. Following the documented convention for gett
- An engineer notices the command `terraform -chdir=environments/prod plan` in a runbook and wonders whether the `-chdir` global option can also be used to print the plan command's usage and its availab
- Two engineers disagree about how to display the usage information for the `init` subcommand. One types `terraform init -help`; the other insists it must be written as `terraform -help init`. According
- An engineer runs `terraform -help` on its own and sees the general help: a list of available commands and the global options. They actually need to review only the specific options that the `terraform
- While preparing to import an existing resource, an engineer wants to review every option that the `terraform import` subcommand accepts, along with its usage, without running an actual import or leavi
- A platform engineer has just cloned an unfamiliar repository and wants to review every option that the `terraform plan` subcommand accepts, together with its usage line, directly from the command line
- A new team member is nervous about experimenting with `terraform apply` in a production working directory and wants to inspect the command's accepted options first. A colleague suggests running `terra
- A developer runs `terraform` with no additional arguments and sees the list of available commands, including `init`. They now want to see exactly which options the `init` subcommand accepts and how it
- Command structure with global options
The Terraform CLI follows the pattern terraform [global options] [args], where global options such as -chdir and -version precede the subcommand name.