SaveMyCert
Log in
5 of 5 free questions left today·for unlimited practice
Terraform 004 practice

Free Terraform 004 practice questions

Drill exam-realistic HashiCorp Certified: Terraform Associate (004) questions by domain, with an explanation on every option — not just the right one. 5 fully worked examples are further down this page, answers included.

Question bank
200
across 8 domains
Free, no account
5/day
sign up free to remove the cap
Real exam
57 Qs
60 min · pass 700
Explanations
Every option
right and wrong

Build a practice session

Domains

How many?

Mode

Ready when you are

10 fresh questions drawn across all domains, in Learn mode.

Focused review

Every question you answer incorrectly, and every question you flag while practising, is saved here automatically. Finish a session and you can come back to re-drill just those.

5 sample Terraform 004 questions, fully explained

Real questions from the Terraform 004 bank, with the answer key and the reasoning behind every option. Read them, then go back up the page and try the rest.

Question 1Infrastructure as Code (IaC) with Terraform

A new team member asks what "Infrastructure as Code" actually means. Which description is most accurate?

Choose one.

  • a
    Defining and managing infrastructure in machine-readable definition files that can be versioned, reviewed, and executed repeatedly Correct

    IaC means infrastructure is described in code (definition files), so it can be stored in version control, peer reviewed, and applied consistently by a tool.

  • b
    Writing application source code that runs directly on cloud servers

    That describes application development. IaC is about describing the infrastructure itself (networks, VMs, DNS), not the apps that run on it.

  • c
    Using a cloud provider's web console with a documented runbook so every engineer clicks the same buttons

    A documented manual process is still manual. IaC replaces console clicks with executable definition files, removing the human from the repetitive steps.

  • d
    Storing screenshots and diagrams of the current infrastructure in a Git repository

    Diagrams are documentation, not code a tool can execute. IaC files are the actual executable source of truth for provisioning.

The concept

Infrastructure as Code (IaC) is the practice of managing infrastructure through machine-readable definition files rather than manual processes or interactive consoles.

Why that’s the answer

The defining property of IaC is that infrastructure lives in files a tool can execute: Terraform reads HCL configuration and creates, updates, or destroys real resources to match it. Because the definitions are plain text, they gain everything source code has — version control history, code review, reuse, and repeatable automated execution. Manual console work with a runbook, diagrams, or the application code itself all lack that executable, versionable definition of the infrastructure.

How to reason it out
  1. Ask whether the infrastructure is described in files a tool can execute — that is the core of IaC.
  2. Check that those files can be versioned and reviewed like any other code.
  3. Eliminate options that describe manual processes (console runbooks) or non-executable artifacts (diagrams, screenshots).

Exam tip: IaC = infrastructure defined in executable, version-controllable definition files, not manual console work.

Infrastructure as Code with Terraform: Concepts and Multi-Cloud Workflows — the lesson that teaches this.

Question 2Terraform fundamentals

A configuration needs the AWS provider from the public Terraform Registry. Which block correctly declares this requirement?

Choose one.

  • a
    terraform { required_providers { aws = { source = "hashicorp/aws", version = "~> 5.0" } } } Correct

    Provider requirements are declared in the required_providers block inside terraform {}, giving each provider a local name, a source address, and an optional version constraint.

  • b
    provider "aws" { source = "hashicorp/aws", version = "~> 5.0" }

    A provider block configures the provider (region, credentials); source and version belong in required_providers, and modern versions of Terraform reject version arguments in provider blocks.

  • c
    resource "terraform_provider" "aws" { source = "hashicorp/aws" }

    There is no terraform_provider resource type; providers are requirements declared in settings, not resources you create.

  • d
    module "aws" { source = "hashicorp/aws", version = "~> 5.0" }

    A module block sources a Terraform module, not a provider plugin; hashicorp/aws is a provider address, not a module address.

The concept

Provider requirements — local name, source address, and version constraint — are declared in the required_providers block within the terraform settings block.

Why that’s the answer

The required_providers block is where a configuration says which providers it depends on and where they come from: source "hashicorp/aws" means the aws provider in the hashicorp namespace of the public registry, and version "~> 5.0" constrains acceptable releases. The provider "aws" block is a different thing — it supplies configuration such as region — and is not where source or version live. Neither resource nor module blocks declare provider plugins.

How to reason it out
  1. Open a terraform {} settings block and add required_providers.
  2. Give the provider a local name (aws) with source = "hashicorp/aws" and a version constraint.
  3. Configure the provider separately in a provider "aws" {} block (region, credentials), then run terraform init to install it.

Exam tip: required_providers declares source and version; the provider block only configures — never confuse the two.

Terraform Providers, Version Constraints, and State Basics — the lesson that teaches this.

Question 3Core Terraform workflow

A new engineer clones a Terraform repository, changes into the directory, and runs terraform plan. The command fails with an error saying the backend has not been initialized and provider plugins are missing. Which command should the engineer run first?

Choose one.

  • a
    terraform init Correct

    init prepares the working directory: it configures the backend, downloads the provider plugins the configuration requires, and installs any modules. It must be run before plan in a freshly cloned directory.

  • b
    terraform validate

    validate checks configuration syntax and consistency, but it also requires an initialized working directory to load provider schemas - it would fail with a similar error here.

  • c
    terraform refresh

    refresh updates state to match real infrastructure. It cannot run without an initialized backend and providers, and it is not part of first-time setup.

  • d
    terraform apply -refresh-only

    A refresh-only apply reconciles state with real infrastructure, but like any state operation it requires the directory to be initialized first.

The concept

terraform init is the mandatory first step in any new or freshly cloned Terraform working directory. It initializes the backend, installs the required provider plugins into the .terraform directory, downloads modules, and creates or verifies the dependency lock file.

Why that’s the answer

Both symptoms in the error - an uninitialized backend and missing provider plugins - are exactly what terraform init fixes. Plan, apply, validate, and refresh all depend on an initialized working directory, so none of them can substitute for init. Once init completes successfully, terraform plan will be able to load providers, read state through the backend, and produce an execution plan.

How to reason it out
  1. Clone the repository and change into the configuration directory.
  2. Run terraform init to configure the backend, install providers, and download modules.
  3. Re-run terraform plan, which can now load provider schemas and read state.

Exam tip: Any freshly cloned Terraform directory needs terraform init before plan, apply, or validate will work.

Terraform init, validate, and plan: the core workflow explained — the lesson that teaches this.

Question 4Terraform configuration

What is the fundamental difference between a resource block and a data block in a Terraform configuration?

Choose one.

  • a
    A resource block creates and manages an infrastructure object, while a data block only reads information about an existing object that Terraform does not manage. Correct

    Correct. Resources are objects Terraform creates, updates, and destroys; data sources are read-only lookups of objects managed elsewhere or provided by the platform.

  • b
    A resource block is evaluated only during terraform apply, while a data block is evaluated only during terraform plan.

    Both resources and data sources participate in both plan and apply. Data sources are typically read during plan (or apply when they depend on unknown values), not exclusively during plan.

  • c
    A data block stores its results outside of state, while a resource block stores its attributes in state.

    Data source results are also recorded in the state file so other expressions can reference them; both kinds of block appear in state.

  • d
    A resource block can only be used with cloud providers, while a data block works with any provider.

    Both resources and data sources are defined by providers of any kind, including local, random, and TLS providers, not just cloud platforms.

The concept

Resources declare infrastructure objects Terraform owns and manages through their full lifecycle. Data sources fetch information about objects that already exist so the configuration can reference them without managing them.

Why that’s the answer

A resource block causes Terraform to create the object on the first apply and to update or destroy it on later runs, while a data block performs a read-only query and never modifies real infrastructure. The distractors describe plausible-sounding but wrong mechanics: data sources are read during plan or apply as needed, their results are stored in state, and both block types exist for every kind of provider.

How to reason it out
  1. Ask whether Terraform should own the object's lifecycle: if yes, use a resource block.
  2. If the object already exists and you only need its attributes, declare a data block instead.
  3. Reference the fetched attributes elsewhere in the configuration, remembering that data sources never change real infrastructure.

Exam tip: resource = create and manage; data = read-only lookup of something Terraform does not manage.

Terraform Resources, Data Sources, Variables, and Outputs — the lesson that teaches this.

Question 5Terraform modules

A configuration contains a module block with source = "modules/network", and the module code exists in a modules/network folder next to the root configuration. terraform init fails with an error about not finding the module in the Terraform Registry. Why?

Choose one.

  • a
    Local module paths must begin with ./ or ../, so Terraform interpreted modules/network as a registry address instead of a local directory. Correct

    Correct. A source that does not start with ./ or ../ is parsed as a remote address. modules/network looks like an incomplete registry path, so init tries the registry and fails. Changing it to ./modules/network fixes it.

  • b
    Local modules must be declared with the path argument instead of source.

    There is no path argument on module blocks. The source argument is used for every module source type, including local directories.

  • c
    Terraform only supports local modules when the directory is named exactly modules/local.

    Terraform imposes no naming convention on local module directories. Any relative path starting with ./ or ../ works.

  • d
    The module directory must first be published to the registry before it can be referenced.

    Publishing is never required for local modules. Local paths are referenced in place directly from disk.

The concept

Terraform decides how to fetch a module purely from the shape of the source string. Anything that does not begin with ./ or ../ is treated as a remote source, and a bare two-part path resembles a registry address.

Why that’s the answer

The prefix ./ or ../ is what marks a source as a local filesystem path. Without it, modules/network is sent to the registry resolver, which fails because it is not a valid namespace/name/provider address. There is no path argument (b), no required directory name (c), and no publishing requirement for local code (d).

How to reason it out
  1. Terraform reads the source string and checks whether it starts with ./ or ../.
  2. Since modules/network has no such prefix, Terraform parses it as a remote registry address.
  3. The registry lookup fails because the string is not a valid registry module path.
  4. Rewriting the source as ./modules/network makes Terraform load the directory from local disk.

Exam tip: Local module sources must start with ./ or ../ or Terraform will treat them as remote addresses.

Terraform Modules: Sourcing, Using, and Versioning Explained — the lesson that teaches this.

The Terraform 004 question bank, by domain

The bank is built to the exam's own weighting, so the practice you get reflects the marks that are actually on offer — not whichever domain was easiest to write questions for.

Published Terraform 004 practice questions per exam domain
DomainExam weightTopicsQuestions
Infrastructure as Code (IaC) with Terraform8%120
Terraform fundamentals11%120
Core Terraform workflow19%240
Terraform configuration22%240
Terraform modules11%120
Terraform state management11%120
Maintain infrastructure with Terraform8%120
HCP Terraform10%120
Total100%10200

How Terraform 004 questions are worded

Most Terraform 004 questions are not asking whether you can recall a definition. They describe a situation and ask which option satisfies it — so the skill being tested is reading the requirement precisely and eliminating options that fail it.

Single-response vs multiple-response

A single-response question has exactly one right answer. A multiple-response question tells you how many to pick ("Choose TWO") and there is no partial credit — getting one of the two right scores nothing. Read that instruction before you read the options.

Read the last line first

The final sentence is the actual question; everything before it is scenario. Read it first, then read the scenario knowing what you are looking for. It stops you from building an answer in your head that the question never asked for.

Hunt for the qualifier

Most scenarios turn on one word — MOST cost-effective, LEAST operational overhead, with the LEAST latency, without changing application code. Two options are frequently both technically correct, and the qualifier is the only thing separating them.

Eliminate, then choose

Distractors are almost always real HashiCorp services doing a real job — just not this job. Rule out the ones that break a stated constraint before you compare what's left. On a question you truly don't know, eliminating two options turns a guess into a coin flip.

Beyond Terraform 004 practice

Terraform 004 practice questions: your questions

Yes. You can answer 5 questions a day with no account at all, and creating a free account removes the daily limit entirely — the full 200-question Terraform 004 bank, with an explanation on every option.