Courseiva

TF-004 Understand Terraform's purpose Practice Question

A team has been managing their AWS infrastructure using a collection of Bash scripts that create resources in a specific order. They frequently encounter issues where resources are created out of order or not properly cleaned up. They want to adopt a more reliable approach that ensures consistent provisioning and teardown. Which action best aligns with Terraform's purpose?

⚠ Common exam trap

TF-004 often tests the misconception that any automation tool (like Ansible) or improved scripting can replace Terraform's declarative state management, when the key differentiator is Terraform's state file and dependency graph.

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

✓

Convert the scripts into Terraform configuration files and use remote state.

Terraform's core purpose is to provide declarative, idempotent infrastructure as code with a state file that tracks resource dependencies and enables consistent provisioning and teardown. Converting the Bash scripts to Terraform configuration files directly addresses the ordering and cleanup issues because Terraform builds a dependency graph and applies changes in the correct order. Using remote state (e.g., S3 backend with DynamoDB locking) ensures the state is shared, consistent, and protected from loss, which is essential for team collaboration and reliable teardown.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Continue using the Bash scripts but add more error handling.

    Why it's wrong here

    While improved error handling is beneficial, Bash scripts are inherently imperative, meaning they specify *how* to achieve a desired state rather than *what* the desired state is. This approach makes managing complex infrastructure challenging, as scripts lack an inherent understanding of resource dependencies and cannot automatically determine the correct order of operations or ensure idempotency. This often leads to brittle, difficult-to-maintain infrastructure as code that is prone to order-of-operation issues.

  • ✗

    Use Terraform but only store state locally on the lead engineer's machine.

    Why it's wrong here

    Storing Terraform state locally on a single machine severely hinders team collaboration, as other engineers cannot access or update the infrastructure's current state, leading to inconsistencies and potential overwrites. Furthermore, local state is vulnerable to data loss if the machine fails or the file is accidentally deleted, making it impossible to manage or destroy the provisioned resources reliably. This approach negates many benefits of Terraform for team environments and introduces significant operational risks.

  • ✓

    Convert the scripts into Terraform configuration files and use remote state.

    Why this is correct

    Converting to Terraform configuration files leverages a declarative approach, allowing the team to define the desired end state of their AWS infrastructure, rather than the steps to get there. Terraform automatically builds a dependency graph, ensuring resources are provisioned in the correct order and handling updates efficiently. Utilizing remote state, such as in an S3 bucket with DynamoDB locking, enables secure team collaboration, prevents concurrent modifications, and maintains a consistent, shared record of the infrastructure's actual state.

  • ✗

    Rewrite the scripts as Ansible playbooks for provisioning.

    Why it's wrong here

    While Ansible is excellent for configuration management and orchestration, it is primarily an imperative tool designed for managing existing servers and applications, not for provisioning cloud infrastructure from scratch. Unlike Terraform, Ansible does not inherently manage a persistent state file that tracks the lifecycle of provisioned resources, making it less suitable for creating, updating, and destroying cloud resources reliably. Its focus is on *how* to configure, rather than *what* infrastructure to create and manage over its full lifecycle.

Quick reference

AWS S3 Storage Class Comparison

Storage ClassMin DurationRetrievalUse Case
S3 StandardNoneImmediateFrequently accessed data
S3 Standard-IA30 daysImmediateInfrequent access, rapid retrieval
S3 One Zone-IA30 daysImmediateNon-critical infrequent data
S3 Intelligent-TieringNoneImmediate–hoursUnknown or changing access patterns
S3 Glacier Instant90 daysMillisecondsArchive with instant retrieval
S3 Glacier Flexible90 daysMinutes–hoursArchive, flexible retrieval
S3 Glacier Deep Archive180 daysHoursLong-term compliance archive

About these practice questions

Courseiva writes every TF-004 question from scratch — 434 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official HashiCorp exam blueprint

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.