10 free sample questions from a bank of 323, with the correct answers and explanations. No signup required — start practising right now.
1The terraform.tfstate file always matches your currently built infrastructure.
True
False
Answer: B
The short version
B — False, state does not always match live infrastructure. Manual console changes, out-of-band edits and failed applies create drift, so the state file reflects last known Terraform view, not guaranteed reality.
Key concepts in this question
State file role: JSON mapping of managed resources to real IDs and attributes, used to plan incremental changes efficiently.
Drift causes: ClickOps edits, auto-scaling events, and provider-side defaults can diverge from recorded values without Terraform awareness.
Refresh behavior: Terraform queries providers during plan to detect some drift, but only for managed attributes and only when a run occurs.
Always claim: Absolute wording fails because any external mutation breaks strict equality between state and infrastructure.
Why B is correct
State records what Terraform last created or refreshed, yet it cannot observe every external action continuously. A user can alter a security group or delete a resource directly, leaving state stale until the next refresh and reconciliation. Because that gap is inherent to declarative tooling, the always-matches statement is false as settled.
Why the others are wrong
A. True is wrong because it assumes continuous perfect tracking, ignoring manual drift and changes made outside Terraform workflows.
Terraform-Associate exam tip
Treat always and never as red flags for state, then recall drift and refresh, since the exam loves testing that state is a cached map, not live truth.
2You have deployed a new webapp with a public IP address on a cloud provider. However, you did not create any outputs for your code.
What is the best method to quickly find the IP address of the resource you deployed?
Run terraform output ip_address to view the result
In a new folder, use the terraform_remote_state data source to load in the state file, then write an output for each resource that you find the state file
Run terraform state list to find the name of the resource, then terraform state show to find the attributes including public IP address
Run terraform destroy then terraform apply and look for the IP address in stdout
Answer: C
The short version
C — Use state list then state show to find the deployed IP. Without declared outputs, the state still holds all resource attributes, so listing addresses and inspecting details reveals the public IP quickly.
Key concepts in this question
State inspection: Read-only commands that reveal managed resource addresses and current attribute values without changing infrastructure.
Outputs contrast: Named values for automation and human consumption, but they must be defined before apply to be queryable via output.
Remote state loading: Useful for cross-configuration references, yet overkill for a quick local lookup of one address.
Destroy and reapply: Wasteful and risky, causing downtime only to view data already stored in state.
Why C is correct
State list enumerates managed instances such as web servers, then state show prints their attributes including public IP fields. This uses authoritative local data with no extra code or disruption. Because outputs were never defined, direct state inspection is the settled fastest and safest method.
Why the others are wrong
A. Run output is wrong because no outputs were declared, so the command has nothing to return.
B. Remote state data source is wrong because creating a new configuration for one lookup adds needless complexity.
D. Destroy then apply is wrong because it interrupts service and risks loss merely to view an address.
Terraform-Associate exam tip
Link missing outputs to state show, declared outputs to output command, and cross-stack needs to remote state, choosing inspection for quick debugging.
3You have declared an input variable called environment in your parent module. What must you do to pass the value to a child module in the configuration?
Add node_count = var.node_count
Declare the variable in a terraform.tfvars file
Declare a node_count input variable for child module
Nothing, child modules inherit variables of parent module
Answer: C
The short version
C — Declare a child input variable to receive the parent value. Modules are encapsulated, so parent values only enter a child through explicit variable passing in the module block.
Key concepts in this question
Module encapsulation: Child modules expose inputs via variable blocks and return data via outputs, with no implicit inheritance.
Passing pattern: Parent sets an argument inside the module call, such as environment equals var dot environment, matching the child variable name.
tfvars role: Supplies values to the root module from files or CLI, but does not automatically forward them into nested children.
Naming note: The example uses node count wording to stress that declaration structure matters more than the illustrative name.
Why C is correct
Without a declared input, the child has no interface to accept the value, and Terraform errors on undeclared arguments. Declaring the input creates the contract, then the parent assignment fulfills it during evaluation. That explicit wiring is the settled requirement for parent-to-child data flow.
Why the others are wrong
A. Add node count assignment alone is wrong because assignment without declaration has no target interface inside the child.
B. Declare in tfvars is wrong because root inputs still need explicit forwarding to reach nested modules.
D. Nothing and inherit is wrong because Terraform modules never inherit parent scope automatically.
Terraform-Associate exam tip
Remember modules are sealed boxes with variable doors, so any pass-value stem needs declare input then assign in the module block.
4If a module declares a variable with a default, that variable must also be defined within the module.
True
False
Answer: B
The short version
B — False, defaults make caller values optional. When a module variable defines a default, the calling configuration may omit it and Terraform uses the preset automatically.
Key concepts in this question
Variable defaults: Fallback values that keep modules usable without forcing every caller to specify each setting.
Required versus optional: Variables without defaults are required inputs, while those with defaults become optional overrides.
Module call shape: The caller supplies only needed arguments, reducing repetition for common environments.
Must wording trap: Absolute must language fails whenever defaults provide a valid path without explicit definition.
Why B is correct
Terraform evaluates the child variable, finds its default, and proceeds when the caller provides no value. Only override scenarios need an explicit assignment. Because defaults exist precisely to avoid mandatory repetition, the claim that the variable must also be defined is false as settled.
Why the others are wrong
A. True is wrong because it treats optional inputs as required, contradicting the documented purpose of defaults.
Terraform-Associate exam tip
Map default to optional and no default to required, so any must-define stem with a default present immediately points to False.
5Which option cannot be used to keep secrets out of Terraform configuration files?
Environment Variables
Mark the variable as sensitive
A Terraform provider
A -var flag
Answer: B
The short version
B — Sensitive marking cannot keep secrets out of configuration files. It only redacts CLI display, while the literal value remains in code, state and logs if placed there.
Key concepts in this question
Sensitive flag: Hides values from plan and apply output to reduce shoulder-surfing exposure.
Secret persistence: Values still reside in tf files, tfvars, environment history and state JSON unless sourced externally.
External secret paths: Environment variables, vault providers, and var flags avoid committing secrets, though each needs careful handling.
Cannot wording: Asks which option fails to solve the stated problem, making the ineffective control the answer.
Why B is correct
Marking sensitive does not relocate the secret, encrypt storage, or prevent state capture, so anyone with file or state access still sees it. True protection requires sourcing from a vault, provider-managed secret, or ephemeral environment injection. Because sensitive only masks display, it is the settled option that cannot keep secrets out.
Why the others are wrong
A. Environment variables are wrong as the answer because they avoid hardcoding secrets when managed securely outside version control.
C. A provider is wrong as the answer because vault-backed providers fetch secrets dynamically without persisting them in code.
D. A var flag is wrong as the answer because CLI-supplied values can avoid committing secrets, with shell history as the remaining caveat.
Terraform-Associate exam tip
Link sensitive to display masking only, and link out-of-file sourcing to real secret hygiene, so cannot-keep-out stems point to sensitive.
6Which of the following arguments are required when declaring a Terraform output?
sensitive
description
default
value
Answer: D
The short version
D — Value is the only required output argument. An output block must declare what it returns, while description and sensitive remain helpful but optional metadata.
Key concepts in this question
Output purpose: Expose computed resource data for users, automation and cross-stack references after apply.
Value argument: Expression evaluated from resources, variables or locals that defines the exported result.
Optional arguments: Description documents intent and sensitive controls display, neither needed for successful initialization.
Default contrast: Applies to input variables, never to outputs, which compute rather than accept fallback input.
Why D is correct
Terraform validates output syntax by requiring the value expression that produces the export. A block with only description has nothing to return and fails validation. Because every working example centers on the value field, it is the settled required argument.
Why the others are wrong
A. Sensitive is wrong because display control is optional and defaults to non-sensitive handling.
B. Description is wrong because documentation improves clarity but is never mandatory for functionality.
C. Default is wrong because outputs do not take defaults, that concept belongs to input variables.
Terraform-Associate exam tip
Recall outputs as value plus optional garnish, pairing with variables as type plus default, to separate required from decorative arguments fast.
7Your risk management organization requires that new AWS S3 buckets must be private and encrypted at rest. How can Terraform Enterprise automatically and proactively enforce this security control?
With a Sentinel policy, which runs before every apply
By adding variables to each TFE workspace to ensure these settings are always enabled
With an S3 module with proper settings for buckets
Auditing cloud storage buckets with a vulnerability scanning tool
Answer: A
The short version
A — Sentinel policy enforces S3 privacy and encryption automatically. As policy as code in Terraform Enterprise, it checks plans before apply and blocks noncompliant buckets proactively.
Key concepts in this question
Sentinel enforcement: Evaluates plan data against rules during the run pipeline, failing the run when controls are violated.
Proactive control: Prevents misconfiguration before infrastructure exists, unlike detective audits that find issues after deployment.
Workspace variables: Supply values per environment but cannot guarantee secure combinations across all modules and authors.
Modules and scanners: Reusable secure modules help and scanners detect drift, yet neither blocks every apply automatically.
Why A is correct
Sentinel runs on every Terraform Enterprise apply, inspecting proposed S3 settings for private access and at-rest encryption. Noncompliant plans are rejected with policy feedback, forcing correction before resources change. That automatic pre-apply gate is exactly the settled proactive enforcement requested.
Why the others are wrong
B. Workspace variables are wrong because per-workspace values are inconsistent and bypassable without a blocking check.
C. S3 module alone is wrong because teams can ignore or misconfigure the module without mandatory validation.
D. Vulnerability scanning is wrong because audits detect after creation rather than preventing the apply.
Terraform-Associate exam tip
Match automatically and proactively plus before every apply to Sentinel, while reusable code maps to modules and after-the-fact maps to audit tools.
8Most Terraform providers interact with ____________.
API
VCS Systems
Shell scripts
None of the above
Answer: A
The short version
A — Most providers interact with APIs. Terraform plugins translate configuration into authenticated API calls that create, read, update and delete managed objects.
Key concepts in this question
Provider architecture: Executable plugins that map resource schemas to upstream service endpoints and handle state translation.
API mediation: Covers cloud, SaaS, DNS and on-prem systems exposing programmatic interfaces for lifecycle control.
VCS and shell contrast: Version control stores code and provisioners run scripts, but neither is the primary channel for resource management.
None trap: Incorrect because documented provider behavior centers on API communication.
Why A is correct
Providers authenticate, paginate, retry and normalize API responses into Terraform state, enabling drift detection and planning. Shell invocation is exceptional and VCS integration supports workflows rather than resource control. Because API interaction defines provider operation, A is the settled answer.
Why the others are wrong
B. VCS systems are wrong because they host configuration and enable automation triggers, not direct resource provisioning.
C. Shell scripts are wrong because local exec is a last-resort provisioner, not the standard provider mechanism.
D. None of the above is wrong because API mediation is well documented as the core provider pattern.
Terraform-Associate exam tip
Think provider equals API translator, so any interact-with stem defaults to API unless the question specifically describes state storage or code hosting.
9terraform validate validates that your infrastructure matches the Terraform state file.
True
False
Answer: B
The short version
B — False, validate checks syntax, not state alignment. It verifies configuration validity and internal consistency without comparing to live infrastructure or stored state.
Plan versus validate: Plan queries providers and state to preview changes, while validate performs no credentialed reads.
State matching: Requires refresh and comparison during plan or external drift tooling, not static validation.
False trigger: The stem overstates validate into infrastructure assurance, which it was never designed to provide.
Why B is correct
Validate runs without needing cloud credentials or current state, catching typos and type errors early. It cannot know whether real resources drifted, were deleted, or differ from state. Because matching infrastructure to state demands live comparison, the claim is false as settled.
Why the others are wrong
A. True is wrong because it confuses static syntax success with dynamic infrastructure conformity, which needs plan or refresh.
Terraform-Associate exam tip
Pair validate with syntax, plan with preview, and apply with change, so any validates-state-or-cloud stem immediately resolves to False.
10What does terraform import allow you to do?
Import a new Terraform module
Use a state file to import infrastructure to the cloud
Import provisioned infrastructure to your state file
Import an existing state file to a new Terraform workspace
Answer: C
The short version
C — Import brings existing infrastructure under state management. It maps a real resource ID into the state so future plans manage rather than duplicate it.
Key concepts in this question
Adoption workflow: Write matching configuration, import by address and ID, then plan to align remaining differences.
State direction: Import moves cloud reality into Terraform state, not state into the cloud as new deployment.
Workspace contrast: Workspaces isolate state environments and do not transfer physical resources between them.
Why C is correct
Import records the current cloud object under a resource address, allowing Terraform to read attributes and propose convergent changes. Without it, apply would attempt duplicate creation or fail on existing names. That bring-under-management function makes C the settled answer.
Why the others are wrong
A. Import module is wrong because modules are referenced with module blocks and registry sources, not import commands.
B. Use state to import to cloud is wrong because it reverses direction, Terraform never pushes a state file as a deployment artifact.
D. Import state to workspace is wrong because workspace moves use state pull and push workflows, not resource import.
Terraform-Associate exam tip
Remember import equals adopt reality into state with config first, then ID, so provisioned-infrastructure-to-state stems always select that mapping.