Exam Information
Free practice questions with explanations
HashiCorp Terraform-Associate-004 Practice Questions
Answer a question to see the correct answer and the explanation, or click Show answer. Newest questions first.
- Questions
- 13
- Answered
- 0
- Correct
- 0
- Score
- -
-
1 Question 1 Single choice Core Terraform workflow
A platform team runs Terraform from a CI pipeline against a shared AWS account. A junior engineer edited a security group rule directly in the console, and now the next scheduled pipeline run must be reviewed before anything changes. The team's policy forbids applying any change that was not reviewed in the plan output, and the pipeline must not modify infrastructure during the review step. Which command should the pipeline run to surface the drift and the proposed changes without altering any infrastructure?
Correct Answer: AExplanationA plan is the only read-only step that computes the diff between configuration, state, and the real infrastructure and saves it for review, which fits the policy that nothing changes before review. Saving it with -out lets the reviewed plan be applied exactly later. The refresh-only apply with auto-approve writes refreshed state without review and violates the policy. Importing targets resources that are already in state rather than reviewing the diff, and removing from state would make Terraform forget the security group entirely, causing it to attempt a recreation later.
-
2 Question 2 Single choice HCP Terraform
A financial services company manages 140 workspaces in HCP Terraform across three business units. Compliance requires that only the central platform team can change the organization's allowed provider versions and that application teams can run plans and applies only in their own workspaces. Application teams must also be able to read outputs from the networking workspace owned by the platform team without gaining edit rights to it. The platform team wants to use the fewest, least-privileged mechanisms available in HCP Terraform. Which approach meets these requirements?
Correct Answer: AExplanationHCP Terraform teams scope workspace permissions, and remote state consumer sharing lets specified workspaces read another workspace's outputs without granting edit rights on it. Owners would give unrestricted control, violating least privilege. Variable sets are for input variables and environment values and would expose outputs insecurely as shared configuration. Granting write access on the networking workspace would allow the application teams to change infrastructure there, which breaks the stated separation.
-
3 Question 3 Single choice Infrastructure as Code (IaC) with Terraform
A logistics company currently provisions its VPCs in AWS by hand and its load balancers in a private VMware cloud through a runbook. Leadership wants one repeatable, reviewable process for both environments, with no separate tooling per cloud, and the team must be able to show auditors the exact configuration deployed on any given date. A key constraint is that the on-premises vSphere API is only reachable through a jump host, and the team cannot install agents on production hosts. Which statement best describes how Terraform addresses this requirement?
Correct Answer: AExplanationTerraform's provider model lets one configuration declare resources across AWS and vSphere, and the configuration and its history can live in version control to satisfy auditors. Connectivity to a private endpoint is configured through the provider, which is where network reachability concerns are addressed. Terraform does not require separate backends per cloud, nor does it need public APIs or host agents, so those alternatives are incorrect.
-
4 Question 4 Single choice Maintain infrastructure with Terraform
A team inherited an AWS S3 bucket that was created manually and has been storing production logs for two years. They must bring it under Terraform management without recreating it, because the bucket holds compliance data and deletion would violate retention rules. The team has written the matching aws_s3_bucket resource block but has not yet run any Terraform commands against the account. Which action should they take next?
Correct Answer: AExplanationThe import command associates an existing real-world object with a resource address in state, and a subsequent plan verifies that the configuration matches reality without proposing replacement. Apply does not adopt unmanaged resources, so it would try to create a duplicate bucket, which conflicts with the bucket name. Pushing an empty state does not link the bucket, and deleting it would destroy compliance data, which the constraint forbids.
-
5 Question 5 Single choice Terraform configuration
A developer is writing a module that creates one aws_instance per entry in a map of application names to instance types. Each instance must receive a tag named Application whose value is the map key. The developer also wants the configuration to fail at plan time if any instance type is not on an approved list. Which combination of constructs best satisfies these requirements?
Correct Answer: AExplanationfor_each over a map gives each instance a stable address keyed by the map key, and each.key supplies the Application tag directly. Variable validation blocks are evaluated during plan and reject values outside an allowed set. Count indexes by position, so removing an entry shifts addresses and destroys unrelated instances, and a precondition is a resource-level check that does not suit a variable-scoped rule as cleanly. Dynamic blocks generate nested blocks rather than resource instances, and ignore_changes would suppress the drift that the team needs to see.
-
6 Question 6 Multiple choice Terraform fundamentals
A company deploys the same web tier to two AWS regions using a single configuration. The security team requires that the state file never store plaintext database passwords generated by Terraform, and that each region's provider use a distinct configuration rather than a shared one. Which TWO actions meet these requirements? (Choose two.)
Correct Answer: A, BExplanationAliased provider blocks let one configuration target several regions with distinct provider configurations, which is the intended pattern for multi-region deployments. Keeping the generated password in an external secrets manager and exposing only a reference means it never lands in plaintext state through Terraform-managed values. Setting an environment variable does not keep a generated secret out of state, since the value still enters state when it is used. Switching a single region variable between runs does not give two concurrent distinct configurations. The local backend does not provide encryption of state contents, so option E is not a real capability.
-
7 Question 7 Single choice Terraform modules
A central platform team publishes a VPC module to a private registry. Application teams pin it with a version constraint in their root configurations. After a breaking change to the module's output names, one application team's pipeline fails after a routine plan because the constraint was written as a bare version with no operator. The team wants a constraint that accepts only patch releases within the 2.4 line, so that fixes are picked up automatically while breaking changes are excluded. Which version constraint should they use?
Correct Answer: AExplanationThe pessimistic constraint operator with a three-part version allows only the rightmost component to increase, so ~> 2.4.0 accepts 2.4.1 and later patches but not 2.5.0. The greater-than-or-equal constraint would allow breaking major and minor releases. The two-part pessimistic form ~> 2.4 would permit 2.5 and 2.9, which is exactly the breaking-change exposure the team wants to avoid. The wildcard form is not valid Terraform version constraint syntax for this purpose.
-
8 Question 8 Single choice Terraform state management
Two engineers in different time zones frequently run terraform apply against the same production state stored in an S3 backend with DynamoDB locking. One engineer's apply was interrupted by a network drop and the lock remains held, blocking all other runs. The on-call lead confirms via the CI system that no apply process is still running. The team must restore normal operations quickly while keeping the state file consistent. What is the correct action?
Correct Answer: AExplanationTerraform reports the lock ID when acquisition fails, and terraform force-unlock releases that specific lock, which is the supported recovery once you are sure no other operation holds it. Deleting state would discard tracked resources and risks duplicate creation. Recreating the lock table destroys all locks and gives no safety for the other runs. Skipping locking with -lock=false removes the protection that prevents concurrent writes to state, which is the very risk the team must avoid.
-
9 Question 9 Single choice Terraform configuration
A data platform team manages a Kubernetes namespace and several databases with Terraform. Their module accepts a list of database objects, each with a name and a size in gigabytes. Business rules require that no database may exceed 500 GB and that the list must contain at least one entry, and these rules must be enforced before any resource is planned. The team also wants an output that lists the names of only the databases larger than 100 GB. Which combination of language features should they use?
Correct Answer: BExplanationVariable validation runs during plan before resources are evaluated, and its condition can express both the non-empty rule and the per-element size limit. A for expression with an if clause produces a filtered list suitable for the output. Preconditions attached to resources run later and would repeat the rule across each resource. Check blocks report warnings rather than enforcing the failure the team needs, and dynamic blocks generate nested blocks, not output values. prevent_destroy protects against deletion and has no bearing on input validation.
-
10 Question 10 Single choice Terraform fundamentals
A team provisions an Azure resource group and a storage account. During a code review, a reviewer notes that the configuration declares the storage account resource with a depends_on list pointing at the resource group, even though the storage account already references the resource group's name attribute. The team wants to keep the configuration minimal and avoid redundant constructs. What is the most accurate assessment of this depends_on entry?
Correct Answer: AExplanationReferencing another resource's attribute creates an implicit dependency, and Terraform's graph uses that to sequence creation and deletion, so depends_on adds nothing here. The claim that references cannot be ordered is false, and depends_on is a resource-level argument, not a provider one. The construct is not what forces replacement, so the replacement claim is wrong. Recognizing redundancy is the correct reading of the configuration.
-
11 Question 11 Multiple choice Terraform state management
A company is moving its Terraform state from local files into a remote backend shared by a team of twelve engineers. The security lead requires that state at rest is encrypted, that concurrent applies against the same workspace are prevented, and that a reliable history of prior state versions is retained for recovery. Which TWO backend choices satisfy all three requirements? (Choose two.)
Correct Answer: B, EExplanationThe S3 backend with server-side encryption, DynamoDB locking, and bucket versioning covers all three requirements, and this is the documented pattern for remote state locking. HCP Terraform's remote backend natively stores encrypted state, locks workspaces during runs, and keeps state version history that can be inspected and restored. Omitting locking fails the concurrency requirement, and a local backend on a shared drive offers no state locking or version history. The Consul option lacks version history, so it fails the recovery requirement.
-
12 Question 12 Single choice Terraform configuration
A cloud operations team needs to pass a database connection password into a resource. The password is currently stored in a terraform.tfvars file committed to the team's repository. An auditor flags this as a secrets exposure. The team must keep the password out of version control and avoid writing it into any file in the repository, while still letting Terraform authenticate at apply time. Which approach is the best practice?
Correct Answer: AExplanationFetching the secret from Vault at runtime keeps it out of the repository and out of Terraform's configuration files, which is what the auditor requires. Adding a tfvars file to .gitignore after it was committed does not remove the value from git history, so the exposure persists. Hard-coding the value places it in the repository, and marking an attribute sensitive only masks CLI output rather than protecting the source. Base64 is an encoding, not encryption, so it provides no real protection.
-
13 Question 13 Single choice Infrastructure as Code (IaC) with Terraform
A financial firm evaluates whether to standardize on Terraform for provisioning across AWS, Azure, and an on-premises Kubernetes cluster. The architecture board is concerned that using a cloud-specific template language would lock them into one vendor's tooling and make multi-cloud environments hard to keep consistent. Which benefit of Terraform's approach most directly addresses this concern?
Correct Answer: BExplanationBecause Terraform uses providers as plugins for each platform, a single HCL workflow can describe AWS, Azure, and Kubernetes resources in one codebase, which addresses the consistency concern. Terraform does not translate resources between clouds, so the conversion claim is false. Native credentials remain necessary for each provider, so claiming they become unnecessary is wrong. Terraform has no mechanism of routing other clouds through one account's billing relationship.
These are 13 of the 385 questions in the full Terraform-Associate-004 pack.
Get All 385 QuestionsGet all 385 questions & answers
Full access options for HashiCorp Terraform-Associate-004
Self-study
PDF Version
- 385 actual exam questions
- Compatible with all devices
- Printable PDF format
- No download limits
- 90 days free updates
- 24/7 customer support
Best value
Bundle Pack
- Discounted PDF + online access
- 385 actual exam questions
- Both PDF and online practice test
- Free 90 days updates
- No download or practice limits
- 24/7 customer support
Exam simulation
Online Practice Test
- 385 actual exam questions
- Actual exam environment
- 90 days free updates
- Browser-based software
- 24/7 customer support
100% Money Back Guarantee
Your success comes first
At DumpsProvider, we give you a 100% money back guarantee on all of our exam dumps. For us, your success is the #1 priority and we are more than confident that our exam material will help you pass the Terraform-Associate-004 Exam (HashiCorp Certified: Terraform Associate (004)) on your very first attempt.
In a rare case, if you fail your exam, we will refund your amount without asking a single question.