Home › Certifications › Terraform Associate 004 › Maintaining Infrastructure
20 multiple-choice questions and 14 flashcards on Maintaining Infrastructure, about 8% of the Terraform Associate 004 bank. Every one carries a written rationale.
Maintaining Infrastructure is one of 8 chapters in CoStudy's Terraform Associate (004) bank, and it holds 20 of the bank's 250 multiple-choice questions — roughly 8% of the total. That proportion is not arbitrary: chapters follow the certifying body's published exam outline, and the number of questions in each is set by that domain's published weight, so the share of your practice time this chapter takes matches the share of the real exam it accounts for.
Studying by chapter is worth doing once you have a diagnostic score. A single overall percentage tells you whether you are close; it does not tell you which domain is dragging. Working a weak chapter in isolation, and re-testing it in isolation, is the fastest way to move a score that has stalled — and it is why the mock exams in CoStudy report by domain rather than as one number.
5 questions drawn from this chapter, with the full rationale shown — the controlling principle behind the right answer, and why each wrong option tempts and fails.
A `moved` block with from = aws_instance.old and to = aws_instance.new has what effect?
Answer: D — Renames the state address to aws_instance.new, leaving the real resource alone.
D is right: the moved block records a refactor, so Terraform updates the address in state and the plan shows a move rather than a replacement. A is exactly what happens if you rename the resource without the block, which is why it tempts. B confuses the operation with a refresh. C would create a duplicate entry. Because it lives in configuration, a moved block is reviewable and runs for everyone, unlike a one-off CLI invocation.
Which command lists every resource address currently tracked in state?
Answer: C — terraform state list
Trick: 'state list' is the subcommand. There is no top-level 'terraform list'. Useful for scripting targeted operations.
What does 'terraform import' do?
Answer: D — Brings an existing resource created outside Terraform under management, recorded in state
D is right: import associates an existing object with a configuration address so Terraform starts managing it; you still write the matching resource block. The config-driven import block is the modern form, since it shows up in plan and can generate configuration. A and B are init behaviours, C is variable loading and E is not what import does.
To replace a single resource on the next apply (modern replacement for the deprecated 'taint'):
Answer: B — terraform apply -replace=<ADDRESS>
Trick: 'taint' is deprecated. The modern flag is 'terraform apply -replace=ADDR' (or 'terraform plan -replace='). 'destroy -target' actually destroys without recreating.
A team wants existing infrastructure brought under management through a reviewable pull request, with the plan showing what will be imported. The BEST approach is:
Answer: D — Add an import block naming the resource address and object ID
A) Terraform never adopts unmanaged objects on its own. B) The CLI command mutates state immediately with no plan preview and no artefact in the repository. C) Hand-editing and pushing state is error-prone and bypasses review entirely. D) Correct — the config-driven import block lives in version control, appears in the plan, and is applied as part of the normal workflow, making it reviewable.
4 cards from the 14 in this chapter.
TF_LOG environment variable?
Sets verbosity. TRACE, DEBUG, INFO, WARN, ERROR. TRACE most verbose.
How do you force a resource to be recreated?
terraform apply -replace=ADDRESS destroys and recreates that one resource in a normal plan and apply. terraform taint is deprecated and should no longer be taught as the answer.
What do the moved and removed blocks do, and which older commands do they replace?
A moved block records that a resource's address changed — renamed, or pulled into a module — so Terraform updates state instead of destroying and recreating; it replaces terraform state mv. A removed block tells Terraform to drop a resource from state while leaving the real object alive, with a lifecycle { destroy = false } argument; it replaces terraform state rm. Both live in configuration, so the change is reviewable and repeatable.
Resource exists but Terraform thinks it doesn't?
terraform import to bring into state.
These are a sample. The full Maintaining Infrastructure chapter runs 34 items with per-chapter progress tracking, on the web and in the iOS app.
Open Terraform Associate 004 in CoStudy →