Home › Terraform 004 › Practice questions › Terraform configuration
Terraform 004 · HashiCorp · Terraform configuration · Bank updated 2026-11-03

Terraform 004 practice questions: Terraform configuration

5 free questions from 29 on this area · answer and explanation for each · no sign-up

These 5 questions come from the Terraform configuration section of our Terraform 004 bank (29 questions on this area, which carries 12.5% of the real exam). Every question is original, with the correct answer explained and linked to the source it is drawn from.

Try 6 free Terraform 004 questions → All Terraform 004 sample questions

Free: 6 questions in study mode, no card. All 29 Terraform configuration questions and the full Terraform 004 bank: $15 one-time.

1/5 · Terraform configuration
A module declares variable "user_names" with type = list(string), and the caller passes ["ana", "ben", "cai"]. A new resource "aws_iam_user" "this" block sets for_each = var.user_names and name = each.value. What happens when the team runs terraform plan?
AThree users are planned, keyed this["ana"], this["ben"], this["cai"]
BThree users are planned, keyed this[0], this[1] and this[2]
CPlanning stops with an error reported on the for_each argument
DPlanning stops with an error reported on the each.value reference
Answer: C. The for_each reference, Usage, states that the meta-argument 'accepts a map or a set of strings and creates an instance for each item in that map or set.' Under Expressions in for_each it adds: 'To prevent unexpected behavior during conversion, the for_each argument does not implicitly convert lists or tuples to sets.' The same page shows toset() and a set(string) variable type as the ways to use a sequence. Source: HashiCorp Terraform Associate (004) exam objectives and Terraform documentation
2/5 · Terraform configuration
A configuration creates subnets with for_each over a map of names. A later expression needs the list of all subnet IDs and is written as aws_subnet.this[*].id. What happens?
AReturns a list of all subnet IDs in key order
BReturns a map of subnet IDs keyed by the names
CFails with an error when Terraform evaluates it
DFails when the map holds two or more subnet entries
Answer: C. Resources declared with for_each appear in expressions as a map of objects, and the splat expression applies only to lists, sets and tuples. The page states that splat expressions cannot be used with for_each resources and recommends a for expression to build a similar result from a map. A splat applied to a single non-null value wraps it in a one-element list, so the .id lookup on the map fails and evaluation stops with an error. Source: https://developer.hashicorp.com/terraform/language/expressions/splat Source: HashiCorp Terraform Associate (004) exam objectives and Terraform documentation
3/5 · Terraform configuration
A root module declares variable "instance_type" with default = "t3.micro". The working directory holds terraform.tfvars containing instance_type = "t3.small" and terraform.tfvars.json containing {"instance_type": "t3.medium"}. No other source assigns the variable, and an engineer runs terraform apply. Which outcome results?
At3.small from terraform.tfvars
Bt3.micro from the default argument
CAn error for assigning instance_type twice
Dt3.medium from terraform.tfvars.json
Answer: D. Terraform loads both files automatically. In the precedence order, the terraform.tfvars.json file comes before terraform.tfvars, and the default argument is lowest. A variable cannot be reassigned within the same file, but two different sources are simply resolved by precedence. Source: tf-language-values-variables, Assign values to variables, p. n/a Source: HashiCorp Terraform Associate (004) exam objectives and Terraform documentation
4/5 · Terraform configuration
A team declares variable "database_password" with sensitive = true and supplies the value at apply time. A reviewer asks what this setting changes for the stored data and the console output. What is the effect?
Athe value is hidden from CLI output but is still stored in state
Bthe value is hidden from CLI output and deleted from state after apply
Cthe value is masked in CLI output and encrypted when stored in state
Dthe value must be supplied through an environment variable
Answer: A. The sensitive argument prevents Terraform from displaying the value in CLI output. Terraform still stores the values of sensitive variables in your state. Source: tf-language-values-variables, Sensitive values in variables, p. 1 Source: HashiCorp Terraform Associate (004) exam objectives and Terraform documentation
5/5 · Terraform configuration
A resource tag Name must read like dev-web-server, where dev comes from var.environment and -web-server is fixed text. Which argument value is correct?
Avar.environment + "-web-server"
B"var.environment-web-server"
C"${var.environment}-web-server"
D"$var.environment-web-server"
Answer: C. References use var.<NAME> syntax, and the pack builds the tag with an interpolation sequence inside a string, as in Name = "${var.environment}-web-server". Source: tf-language-values-variables, Reference variable values, p. 1 Source: HashiCorp Terraform Associate (004) exam objectives and Terraform documentation
Try 6 more free Terraform 004 questions → See the whole Terraform 004 bank

Other Terraform 004 areas

The same kind of free sample for every other section of the Terraform 004 bank:

Infrastructure as Code (IaC) with Terraform29 qTerraform fundamentals38 qCore Terraform workflow33 qTerraform modules28 qTerraform state management44 qMaintain infrastructure with Terraform23 qHCP Terraform24 q

Practise Terraform 004 with instant feedback

6 free questions in study mode · no card · full Terraform 004 bank with area filters and the error log: $15 one-time · no dumps, no ads.

Start Terraform 004 free →
Read next
Terraform Associate 004 vs 003: What Changed and How to Prepare in 2026 HashiCorp retired Terraform Associate 003 on 8 January 2026. What 004 changed, the four new topics, what it means for 003 holders, and a 5-week plan.
ExamDeck is an independent study tool, not affiliated with, endorsed by, or sponsored by HashiCorp. Terraform 004 and related marks are trademarks of their respective owners, used for identification only. Exam facts checked against official HashiCorp materials (as of October 2026); always confirm current details with the vendor before booking.