SaveMyCert
Log in
5 of 5 free questions left today·for 10 a day
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
397
across 8 domains
Free, no account
5/day
a free account allows 10 a day
Real exam
57 Qs
60 min · pass Pass / fail
Explanations
Every option
right and wrong

Build a practice session

5 free questions left today.

Domains

How many?

Mode

Ready when you are

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

Review what you missed

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" means in practice. Which description is most accurate?

Choose one.

  • a
    Writing the application code that runs on servers and deploying it through an automated CI/CD pipeline

    That is application delivery. IaC describes the infrastructure itself (networks, VMs, DNS), not the application code deployed onto it.

  • b
    Describing infrastructure in machine-readable files that a tool applies and that are kept in version control Correct

    IaC means the infrastructure is defined in executable definition files: a tool such as Terraform applies them, and because they are text they can be versioned and reviewed.

  • c
    Following a version-controlled runbook so each engineer performs the same console steps in the same order

    Versioning the instructions does not make the work code. A human still clicks through the console, so nothing is executed from the definition.

  • d
    Keeping version-controlled diagrams that document each network, server and DNS record in the infrastructure

    Diagrams are documentation. No tool can execute them to create or change the infrastructure they describe.

The concept

Infrastructure as Code (IaC) is the practice of managing infrastructure through machine-readable definition files that a tool executes, instead of manual processes or interactive consoles.

Why that’s the answer

The defining property of IaC is that the infrastructure lives in files a tool can execute: Terraform reads HCL configuration and creates, updates or destroys real resources to match it. Because the files are plain text they also gain everything source code has: history, review and repeatable runs. The tempting distractors also mention version control, but a versioned runbook is still a manual process and versioned diagrams are not executable, so neither is code that provisions anything.

How to reason it out
  1. Ask whether a tool executes the definition to build the infrastructure; that is the core of IaC.
  2. Notice that version control alone is not enough: runbooks and diagrams can be versioned too.
  3. Separate infrastructure from application code: deploying apps is CI/CD, not IaC.

Exam tip: IaC = infrastructure defined in files a tool executes, not instructions or pictures for humans.

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

Question 2Terraform fundamentals

A configuration must depend on the AWS provider from the public Terraform Registry, held to the 5.x release line. Which block declares this?

Choose one.

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

    A provider block configures a provider (region, credentials). Source belongs in required_providers, and the version argument in a provider block is deprecated in favour of required_providers.

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

    Provider dependencies are declared in required_providers inside the terraform block: a local name (aws), a source address and a version constraint.

  • c
    terraform { required_version = "~> 5.0" provider "aws" { source = "hashicorp/aws" } }

    required_version constrains the Terraform CLI, not a provider, and a provider block cannot be nested inside the terraform block.

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

    A module block calls a Terraform module. hashicorp/aws is a provider source address, so this neither declares nor installs the provider plugin.

The concept

Provider requirements (local name, source address, version constraint) are declared in the required_providers block inside the terraform settings block.

Why that’s the answer

required_providers is where a configuration states which provider plugins it needs and where they come from: source = "hashicorp/aws" is the aws provider in the hashicorp namespace of the public registry, and version = "~> 5.0" allows any 5.x release. The tempting near-twin puts the same arguments in a provider block, but that block only supplies settings such as region; its version argument is deprecated. required_version looks similar but constrains the Terraform CLI itself, and a module block sources modules, not plugins.

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

Exam tip: required_providers declares which plugin and version; the provider block only says how to connect.

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 configuration directory, and runs terraform plan. The command fails, reporting that the required provider plugins are not installed and the state backend is not set up. Which command should the engineer run first?

Choose one.

  • a
    terraform validate

    validate checks configuration syntax and consistency, but it needs provider schemas from an initialized working directory, so it would fail with a similar error here.

  • b
    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.

  • 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 get

    get downloads the modules declared in the configuration, but it never installs provider plugins or configures the backend, so plan would still fail.

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. validate and refresh depend on an initialized working directory, and terraform get fetches modules only, so none of them can substitute for init. Once init completes, terraform plan can 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 core difference between a resource block and a data block in a Terraform configuration?

Choose one.

  • a
    A resource block creates and manages an object; a data block only reads an existing object. Correct

    Correct. Terraform owns the lifecycle of a resource (create, update, destroy), while a data source is a read-only lookup of something managed elsewhere or published by the provider.

  • b
    A resource block is evaluated only during apply; a data block is evaluated only during plan.

    Both block types take part in plan and apply. Data sources are usually read during plan, but Terraform defers the read to apply when the data source depends on values not yet known.

  • c
    A resource block records its attributes in state; a data block keeps its query results out of state.

    Data source results are also recorded in state so other expressions can reference them; the difference is that Terraform does not manage the underlying object.

  • d
    A resource block works with cloud providers only; a data block works with any kind of provider.

    Providers of every kind (random, tls, local, cloud platforms) can offer both resource types and data sources; the block type is not tied to the provider category.

The concept

Resources declare infrastructure objects Terraform owns through their whole lifecycle. Data sources fetch information about objects that already exist so the configuration can use it without managing those objects.

Why that’s the answer

A resource block makes Terraform create the object on the first apply and update or destroy it on later runs. A data block performs a read-only query and never changes real infrastructure. The other statements describe tempting but wrong mechanics: data sources are read during plan or apply as needed, their results are stored in state, and both block types are available from providers of any kind.

How to reason it out
  1. Ask whether Terraform should own the object's lifecycle: if yes, it is a resource.
  2. If the object already exists and only its attributes are needed, it is a data source.
  3. Remember that both appear in state, and both are offered by providers of every kind.

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 root configuration keeps module code in a modules/network directory beside its own .tf files and calls it with source = "modules/network". terraform init fails, reporting an invalid module source address. What change fixes the configuration?

Choose one.

  • a
    Change the source value to "./modules/network". Correct

    Correct. A local path source must begin with ./ or ../. With the prefix, Terraform loads the directory in place relative to the calling module.

  • b
    Change the source value to "/modules/network".

    A leading slash makes this an absolute filesystem path, which points at /modules/network at the root of the disk, not the directory beside the configuration.

  • c
    Move the directory to .terraform/modules/network.

    .terraform/modules is the cache Terraform manages for installed remote modules. Moving code there does not change how the source string is parsed, and init can overwrite that cache.

  • d
    Run terraform get before running terraform init.

    terraform get runs the same module-installation step as init, so it fails on the same source string. The problem is the address, not the command.

The concept

Terraform decides how to obtain a module from the shape of the source string. Only strings that begin with ./ or ../ are treated as relative local paths; anything else is parsed as a remote address such as a registry module.

Why that’s the answer

Without the ./ prefix, modules/network does not match the local-path form, so Terraform tries to parse it as a remote address and fails. Adding ./ is the whole fix. A leading slash turns it into an absolute path to a different location, the .terraform/modules directory is a cache rather than a source location, and terraform get performs the same installation step and hits the same error.

How to reason it out
  1. Read the source string and check whether it starts with ./ or ../.
  2. Recognise that an unprefixed path is parsed as a remote address, not a folder.
  3. Add the ./ prefix so the path resolves relative to the calling module.
  4. Re-run terraform init, which now loads the directory in place.

Exam tip: Local module sources must start with ./ or ../; without the prefix Terraform treats the string as a remote address.

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%132
Terraform fundamentals11%143
Core Terraform workflow19%276
Terraform configuration22%286
Terraform modules11%144
Terraform state management11%144
Maintain infrastructure with Terraform8%132
HCP Terraform10%140
Total100%10397

Practise Terraform 004 one domain at a time

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.

Practise Terraform 004 from your browser

The SaveMyCert Chrome extension opens a daily drill of 5 Terraform 004 questions in the side panel, with the full explanation behind every answer. No account needed.

Get the Chrome extension (opens in a new tab)

Beyond Terraform 004 practice

Terraform 004 practice questions: your questions

Yes. You can answer 5 questions a day with no account at all, and a free account raises that to 10 a day across the full 397-question Terraform 004 bank, with an explanation on every option. Pro removes the daily cap entirely.

Source

Exam structure, domain weights and scoring on this page come from the official Terraform 004 exam guide.