TF-IEP002 Study Notes in Questions: Terraform configuration

Practice Terraform configuration for the HashiCorp Terraform Infrastructure Engineer Professional (002) (TF-IEP002) exam with the 5 questions below. Every option is explained, so a wrong pick still teaches something.

TF-IEP002 Terraform configuration: 5 practice questions

HashiCorp Terraform Infrastructure Engineer Professional (002) (TF-IEP002) · Terraform configuration · 5 questions with answers and explanations

📊 About this set

Exam: TF-IEP002 · 60 questions · 90 minutes
This set: 4 applied, 1 advanced · 2 troubleshooting, 1 comparison, 1 scenario, 1 trade-off · 1 with more than one answer
Topics: Terraform

Question 1 of 5

Which TWO expressions evaluate to the list ["a", "b", "c"]? (Select TWO)

Aflatten([["a"], ["b", ["c"]]])
Bcompact(["a", "", "b"])
Cslice(["a", "b", "c", "d"], 1, 3)
Dconcat(["a"], [["b", "c"]])
Edistinct(["a", "b", "a", "c"])
Show answer

✅ Answer: A, E

Difficulty: applied · Topic: Terraform

Shape-changing list functions
• flatten removes all levels of nesting from a list of lists, however deep, and keeps element order.
• concat joins lists end to end but does not flatten: a list given as an element stays a nested list.
• distinct drops duplicates, keeping the first occurrence of each element and the original order.
• compact removes empty strings (and nulls) from a list of strings.
• slice(list, start, end) returns elements from start up to but not including end.

Why each option works or fails
• ✓ A. flatten (correct): recursion removes both nesting levels, giving ["a", "b", "c"].
• ✗ B. compact: drops the empty string and returns ["a", "b"]; there is no "c".
• ✗ C. slice from 1 to 3: starts at the second element and stops before index 3, so it returns ["b", "c"].
• ✗ D. concat with a nested list: the second argument contributes the single element ["b", "c"], so the result is ["a", ["b", "c"]].
• ✓ E. distinct (correct): the second "a" is dropped and order is kept, giving ["a", "b", "c"].

Question 2 of 5

A root module requires aws with version = "~> 5.40"; the lock file records 5.42.0, and 5.60.0 and 6.0.0 have since been released. What does a plain terraform init select, and what does terraform init -upgrade select?

APlain init selects 5.60.0; -upgrade selects 6.0.0
BPlain init selects 5.42.0; -upgrade selects 6.0.0
CPlain init selects 5.40.0; -upgrade selects 5.42.0
DPlain init selects 5.42.0; -upgrade selects 5.60.0
Show answer

✅ Answer: D

Difficulty: applied · Topic: Terraform

Constraint versus lock file
• ~> 5.40 allows >= 5.40.0, < 6.0.0: the rightmost component may increase. (~> 5.40.0 would allow only 5.40.x.)
• Plain terraform init reuses the version recorded in the lock file if it still satisfies the constraint, so builds stay reproducible.
• terraform init -upgrade ignores the recorded selection and picks the newest version the constraint allows, then rewrites the lock file.
• 6.0.0 is outside the range, so only a change to the constraint can select it.

Why each option works or fails
• ✗ A. Latest on plain init: that would ignore the lock file, and 6.0.0 is excluded by the constraint.
• ✗ B. Upgrade to 6.0.0: the upper bound of ~> 5.40 is below 6.0.0.
• ✗ C. Lowest allowed: Terraform does not pick the minimum; it uses the locked version or the newest allowed one.
• ✓ D. 5.42.0, then 5.60.0 (correct): init honours the lock, and -upgrade takes the newest release inside ~> 5.40.

Question 3 of 5

A platform team owns the shared network, and many application teams deploy into it. The platform team must be able to change the network without touching application state. What is the best composition?

ACopy the network resources into each application root module so that each team can adjust its own network when needed
BGive the network its own root module and state, and let each application read the IDs it needs through data sources or outputs
CStore the network IDs in a variable file in each application repository, edited by hand whenever a network change lands
DKeep the network and every application in one root module so that a single plan shows the combined effect of all changes together
Show answer

✅ Answer: B

Difficulty: applied · Topic: Terraform

Composition and blast radius
How you divide configuration into root modules decides who can change what and how big a mistake can be. Every root module has its own state and its own plan.
• Split along ownership and change rate: a slow-moving shared network is separate from fast-changing applications.
• Consumers need the network's identifiers. They can read published outputs (for example through a remote state data source) or look objects up with data sources filtered by tag or name.
• Each application plan then only touches that application, and the network team plans without any application resources in scope.
A monolith has one plan and one lock for everyone, so unrelated teams block each other and a single mistake can reach the network.

Why each option works or fails
• ✗ A. Copied network resources: duplicating the resources would make each root try to manage its own network, creating several competing definitions rather than one shared network.
• ✓ B. Separate roots with data/output lookups (correct): ownership matches state boundaries, applications read network facts instead of managing them, and neither side can destroy the other's resources by accident.
• ✗ C. Hand-edited variable files: IDs go stale whenever the network is rebuilt and nothing links them to the real objects; lookups remove the manual step.
• ✗ D. Single root: one state and one lock is shared by all teams, so changes queue up and every plan includes resources a team does not own.

Question 4 of 5

The root module sets instance_type = "m5.xlarge" in tfvars and declares variable "instance_type", but the deployed instances stay t3.micro. The call is module "app" { source = "./app" }, and the module's own variable defaults to t3.micro. What explains it?

AThe tfvars file is read by the module, but the module ignores it because defaults take priority in child modules
BThe root variable is never passed into the module call, so the module keeps its default value
CThe instance type is cached in state, so changing a variable has no effect until the state is deleted
DTerraform copies variables with the same name into child modules but only for variables without a default
Show answer

✅ Answer: B

Difficulty: applied · Topic: Terraform

Variables do not cross module boundaries automatically
Every module, root or child, has its own input variables. A value set in tfvars or the CLI feeds the root module's variable only. The root must pass it explicitly: instance_type = var.instance_type inside the module block. Without that argument the child uses its default (or prompts if it has none).
• When a value does not show up, trace the chain: tfvars → root variable → module argument → child variable → resource argument.
• Running terraform plan and reading the module's resource arguments shows where the chain stops.
Nothing is shared by name; this is what lets module inputs stay a clear contract.

Why each option works or fails
• ✗ A. Defaults beat tfvars: tfvars feed only the root module; a child default applies simply because nothing was supplied.
• ✓ B. Missing module argument (correct): the root variable has the right value, but it is never handed to the child, so the child default t3.micro applies.
• ✗ C. State cache: state stores what exists; a configuration change that reaches the resource produces a plan diff, and deleting state is never needed.
• ✗ D. Same-name copying: Terraform has no implicit passing of variables between modules.

Question 5 of 5

A team starts the Terraform MCP server with TRANSPORT_MODE=streamable-http on a shared build host, but colleagues' clients cannot connect to port 8080. Local requests on the host work. What is the most likely cause?

AThe MCP endpoint path is /health by default, so clients must use that path instead
BStreamable HTTP supports only one client per server instance, and the first one blocks the rest
CHCP Terraform must be configured as the identity provider before remote clients connect
DThe server listens only on 127.0.0.1 by default, so TRANSPORT_HOST must be changed
Show answer

✅ Answer: D

Difficulty: advanced · Topic: Terraform

Running the server for several users
The server defaults to the stdio transport, which suits a local client that starts the server process. For a shared deployment you switch to streamable HTTP with TRANSPORT_MODE=streamable-http.
• It binds to 127.0.0.1 on port 8080 with endpoint /mcp by default (TRANSPORT_HOST, TRANSPORT_PORT, MCP_ENDPOINT).
• To accept connections from other machines, set TRANSPORT_HOST to an interface such as 0.0.0.0, and protect the endpoint with TLS (MCP_TLS_CERT_FILE and MCP_TLS_KEY_FILE), allowed origins, and the organization allowlist.
• /health is a status endpoint, not the MCP endpoint.

Why each option works or fails
• ✗ A. Endpoint path: the MCP endpoint is /mcp by default; /health only reports server status.
• ✗ B. One client only: nothing limits the server to one client; limits are per-session rate limits.
• ✗ C. HCP Terraform as IdP: the server does not need it; access can be limited with an organization allowlist, and token handling is separate.
• ✓ D. Loopback binding (correct): the default host is 127.0.0.1, which matches the symptom, so remote clients are refused until the host is changed.

🎯 Takeaways

• flatten is recursive, concat is not; distinct keeps first occurrences in order; slice's end index is exclusive.
• Plain init keeps the locked version; -upgrade moves to the newest version within the constraint, never past it.
• Split roots by owner and change rate, and connect them with outputs or data-source lookups, not copies.
• Inputs are passed explicitly at each module call; trace tfvars to variable to module argument.
• Streamable HTTP binds to 127.0.0.1 by default; set TRANSPORT_HOST (and TLS) to serve other machines.

🔗 Related practice sets

• Can You Answer These 5 TF-IEP002 Questions on Terraform configuration?
• State management and upgrades: 5 TF-IEP002 Questions with Full Explanations
• All TF-IEP002 practice sets
• Every exam on this blog

📚 More TF-IEP002 practice

More TF-IEP002 questions: https://hyunhp.github.io/cert-bank/#exam=TF-IEP002
Study guide: https://hyunhp.github.io/cert-bank/study.html#exam=TF-IEP002

These are original practice questions, not real exam questions, and cert-bank is not affiliated with any certification vendor.

Original practice questions written for this blog, not exam dumps.

Comments