Limited-Time Offer: Enjoy 50% Savings! - Ends In 0d 12h 6m 17s Coupon code: 50OFF

HashiCorp Terraform-Associate-004 Exam Questions & Answers (November 2026)

HashiCorp Certified: Terraform Associate (004) exam questions with 24 free practice questions and explained answers. Updated November 18, 2026. ยท See all HashiCorp exams

Answer 24 scenario questions on this page and see your score as you go. No sign-up needed.

Exam Details

Exam Code
Terraform-Associate-004
Vendor
HashiCorp
Duration (minutes)
60
Languages
English
Delivery
Online Proctored
Question Types
Single Choice
Official Page
View Exam Page
1

Infrastructure as Code (IaC) with Terraform

This topic covers Infrastructure as Code and the benefits of defining infrastructure through code instead of manual steps. Candidates must understand how Terraform supports consistent workflows across cloud platforms, hybrid environments, and services.

Question 1 of 24 Single Choice

A retail company operates separate cloud accounts for development, testing, and production. Each team currently provisions a similar network and application environment by following a written checklist, but small differences appear between accounts after staff changes. The company wants a process that can recreate the baseline consistently and keep its definition under version control without requiring each team to repeat manual steps.

Which benefit of Infrastructure as Code most directly addresses the team's need?

Show Answer

Correct Answer

A

Option A is correct because version-controlled definitions let the teams reproduce the same baseline across accounts and regions. Option B is not correct because code does not replace review of proposed changes. Option C is not correct because providers expose different services and capabilities. Option D is not correct because Infrastructure as Code does not remove the need to monitor running infrastructure.

Question 2 of 24 Single Choice

A financial services team must provide auditors with evidence for changes to its non-production and production environments. Staff currently make some changes through provider consoles, then record them in a ticket, which makes it difficult to determine exactly what was changed. The team plans to manage infrastructure definitions in a version-controlled repository and requires peer review before approved changes are applied.

Which advantage of the proposed Infrastructure as Code approach best meets the audit requirement?

Show Answer

Correct Answer

A

Option A is correct because the repository history and review process can show what infrastructure definition changed and who reviewed it. Option B is not correct because reviewable code cannot guarantee outage-free deployments. Option C is not correct because code review does not replace the required business approval. Option D is not correct because the audit requirement does not require a single provider.

Question 3 of 24 Single Choice

A media company runs customer-facing systems in AWS and Azure, keeps a small virtualization cluster in its own data center, and uses a separate hosted DNS service. Each platform has different APIs, and the company does not plan to migrate them into one environment. Its operations team wants to manage infrastructure changes using a consistent Infrastructure as Code approach while keeping platform-specific capabilities available.

Which statement best describes how Terraform can meet the company's cross-platform requirement?

Show Answer

Correct Answer

A

Option A is correct because the company can use Terraform providers for its cloud, virtualization, and DNS platforms while retaining each provider's resource behavior. Option B is not correct because Terraform does not make provider capabilities identical. Option C is not correct because providers can manage services beyond public cloud infrastructure. Option D is not correct because Terraform can work across multiple platforms.

2

Terraform fundamentals

This topic covers provider installation and version selection, using providers in configurations, and the role of state in Terraform. Candidates must be able to interpret provider selections, use multiple provider configurations, and explain how state connects Terraform resources to remote objects.

Question 4 of 24 Single Choice

A team maintains a configuration that requires the AWS provider at any version greater than or equal to 5.0.0 and less than 6.0.0. The repository includes a dependency lock file that records version 5.18.0 with checksums. An engineer checks out the repository on a new workstation and has not previously installed this provider there.

What will Terraform normally do when the engineer runs terraform init on the new workstation?

Show Answer

Correct Answer

A

Option A is correct because the lock file selects version 5.18.0, and that version satisfies the declared constraint. Option B is not correct because normal initialization uses the locked selection rather than automatically choosing the newest version. Option C is not correct because a prior plan does not override the current constraint. Option D is not correct because provider plugins are installed separately.

Question 5 of 24 Single Choice

A company deploys resources into two AWS accounts from one root configuration. The default AWS provider uses profile primary and region us-east-1 for account 111111111111. A second provider block has alias west, uses profile archive, and targets account 222222222222 in us-west-2. The archive bucket resource explicitly sets provider to aws.west.

Which AWS account and region will Terraform use for the archive resource?

Show Answer

Correct Answer

B

Option B is correct because the resource names aws.west, whose provider configuration specifies account 222222222222 and region us-west-2. Option A is not correct because an explicit provider reference overrides the default configuration. Option C is not correct because the alias selects the entire configuration, including its region. Option D is not correct because aliases allow multiple provider configurations.

Question 6 of 24 Single Choice

An operations team writes a Terraform resource block for a production database that was created manually several months ago. The database is still reachable through the configured cloud provider, but the team's state file contains no entry for it. During a plan, Terraform proposes creating a database that would have the same intended name and settings as the existing one.

Why does Terraform plan to create a new database instead of showing the existing database as managed?

Show Answer

Correct Answer

B

Option B is correct because Terraform uses state to associate a configured resource instance with its remote database, and this state has no such association. Option A is not correct because providers do not generally discover and adopt arbitrary remote objects. Option C is not correct because the lock file records provider selections, not managed objects. Option D is not correct because provider configuration supplies connection details.

3

Core Terraform workflow

This topic covers the commands used to prepare, check, plan, apply, and remove infrastructure from a Terraform working directory. Candidates must choose the appropriate commands and use them in the correct order, including formatting configurations and reviewing planned changes.

Question 7 of 24 Single Choice

A team is preparing a scheduled release from a checked-out Terraform working directory. The change has passed code review, but the operations lead must inspect the proposed infrastructure changes before anything is applied. The team also requires the applied changes to match the exact plan file that was reviewed, rather than a newly generated plan.

Which command sequence should the engineer use to produce the plan for review and then apply that exact reviewed plan?

Show Answer

Correct Answer

B

Option B is correct because saving the plan to `release.tfplan` lets the reviewers inspect that proposal, and applying that file uses the reviewed plan. Option A applies changes before review. Option C checks the configuration but does not create a plan for review. Option D applies a newly generated plan rather than the file the team reviewed.

Question 8 of 24 Single Choice

A developer has cloned a repository containing Terraform configuration that refers to a child module and a cloud provider. The checkout has no `.terraform` directory because it is a fresh clone, and the developer has not run any Terraform commands in it. Before checking the configuration or producing a plan, the developer needs to prepare the working directory.

Which command should the developer run first?

Show Answer

Correct Answer

A

Option A is correct because `terraform init` prepares the new working directory and installs the required modules and providers before the developer runs checks or creates a plan. Option B requires initialization first. Option C can check formatting but does not prepare the directory. Option D also requires initialization before Terraform can plan the configuration.

Question 9 of 24 Single Choice

A test environment is managed from a dedicated Terraform working directory, and the team has completed its final validation. The configuration files must remain in place for a later recreation, but all infrastructure managed by this directory must now be removed. The operator must be able to inspect the proposed removals and confirm before Terraform makes changes.

Which command should the operator run to begin the standard interactive workflow for removing the managed infrastructure?

Show Answer

Correct Answer

C

Option C is correct because `terraform destroy` presents a proposed removal plan and requests confirmation before destroying the environment. Option A applies the configuration instead of starting the destroy workflow. Option B generates a destroy plan but does not apply it. Option D skips the confirmation the team requires before removal.

4

Terraform configuration

This topic covers how to write Terraform configuration with resources, data sources, variables, outputs, expressions, and dependencies. Candidates must be able to validate inputs and configuration, use structured values correctly, and handle sensitive information with care.

Question 10 of 24 Single Choice

A team is adding an EC2 instance to an existing application VPC. The required private subnet already exists and has a stable Name tag, but its ID differs between development and production. The configuration must create a new security group for the instance and avoid embedding environment-specific subnet or security group IDs as literal strings.

Which configuration approach meets these requirements?

Show Answer

Correct Answer

A

Option A is correct because the subnet already exists, so a data block reads its ID, while the new security group is managed as a resource and referenced through its attribute. Option B would try to manage the existing subnet as a new resource. Option C would only look up, not create, the security group. Option D avoids the required cross-resource references.

Question 11 of 24 Single Choice

A platform team maintains one security group configuration for several applications. Each application supplies a different number of ingress rules, and every rule includes numeric port values, a protocol, and a list of CIDR ranges. The team wants a typed input that rejects mismatched structures and generates the nested ingress blocks without duplicating the resource configuration.

Which configuration correctly creates one ingress block for each rule in the input variable?

Show Answer

Correct Answer

A

Option A is correct because the list of objects represents multiple rules, and a dynamic block generates an ingress block for each object using the default iterator ingress. Option B uses for_each on a nested block, which is not supported. Option C declares strings but accesses object attributes. Option D describes only one object, not a collection of rules.

Question 12 of 24 Single Choice

A team launches an EC2 worker with an instance profile and separately attaches an IAM policy to the role used by that profile. The instance configuration references the instance profile, but it has no reference to the policy attachment. Application startup requires the policy to be attached before the instance is created, and the team wants Terraform to represent that ordering directly in the configuration.

Which configuration ensures that the instance creation waits for the policy attachment, even though the instance does not reference an attribute from that attachment?

Show Answer

Correct Answer

A

Option A is correct because an explicit depends_on adds the policy attachment to the instance's dependency graph, so Terraform orders its creation first. Option B supplies an attribute rather than a resource reference in the required list. Option C reverses the dependency and can create a cycle. Option D cannot use a precondition to establish this resource ordering.

5

Terraform modules

Terraform modules let teams organize reusable configuration and obtain modules from local paths, registries, or other supported sources. Candidates must connect module inputs and outputs correctly and choose version constraints that meet the configuration's requirements.

Question 13 of 24 Single Choice

A platform team keeps its root Terraform configuration in a repository alongside a reusable network module in a directory named modules/network. The team wants each environment to use that checked-in module and review changes to it in the same repository. The module is not published in a registry, and the team does not want to download it from a remote source.

Which source should the team use for the module call?

Show Answer

Correct Answer

A

Option A is correct because the module directory is inside the root configuration, so a relative path beginning with ./ identifies it as a local module source. Option B names a registry module, not the local directory. Option C is not the standard registry source address format. Option D does not identify a valid local path or complete registry address.

Question 14 of 24 Single Choice

An operations team has a root configuration with a string input named region. It calls a child module that declares a required string input named deployment_region, and the child uses that input when creating regional services. The root configuration must continue accepting region because other environment files already set it. The team wants the child to receive the configured value without changing its interface.

Which module block change correctly supplies the value required by the child module?

Show Answer

Correct Answer

A

Option A is correct because the module call must explicitly pass the root variable value to the child input named deployment_region. Option B is not correct because child modules do not inherit root input variables automatically. Option C defines an output, which does not provide an input to the child. Option D changes a root variable name but still does not pass its value.

Question 15 of 24 Single Choice

A delivery team uses a module from the Terraform Registry to configure a shared logging service. Its current deployment has been tested with release 3.4.1, and a later release changed an input default that the team has not reviewed. The team wants new working directories initialized from this configuration to select the tested release until a deliberate update is approved.

Which change best ensures that this configuration selects the exact module release already validated by the team?

Show Answer

Correct Answer

A

Option A is correct because the module block can specify an exact registry module release with version set to 3.4.1. Option B constrains Terraform CLI versions, not module releases. Option C allows other compatible 3.x releases, so it does not select the exact tested version. Option D is not the syntax for specifying a registry module version.

6

Terraform state management

This topic covers local and remote backends, state locking, and the migration of state between backends. Candidates must also recognize infrastructure drift and choose state operations that preserve the intended relationship between Terraform and remote objects.

Question 16 of 24 Single Choice

A service team has managed a production environment from a local backend, with the state file stored in its working directory. The team has now configured a remote backend and must move the existing state there before the next change. The managed objects must remain tracked, and the migration must not create or delete infrastructure.

Which action should the team take to move the existing state into the configured remote backend?

Show Answer

Correct Answer

A

Option A is correct because `terraform init -migrate-state` copies the existing local state into the newly configured backend while preserving the managed objects. Option B is not correct because `-reconfigure` changes the backend association without migrating the state. Option C is not correct because removing state entries would leave the objects unmanaged. Option D is not correct because it disables backend initialization.

Question 17 of 24 Single Choice

A small operations group uses Terraform's local backend from a shared checkout on one build host. An apply is running in one shell and updating a long-lived environment. A second operator starts a plan from another shell and receives a state lock error. The first operator reports no failure and is still watching the apply output. What should the second operator do?

What should the second operator do?

Show Answer

Correct Answer

C

Option C is correct because the local backend locks the shared state file, and the first operator is still running an active apply. Option A bypasses the protection against concurrent state operations. Option B is not appropriate because the lock is not stale. Option D is not correct because the local backend supports state locking.

Question 18 of 24 Single Choice

A database administrator changed a managed database parameter directly during an incident, and the operations team has approved keeping that value. The resource remains in Terraform configuration, and the database is healthy. The team wants state to reflect the current remote value, but must not make further infrastructure changes during this maintenance window. What action should the operator take?

Which action records the accepted external change in Terraform state without changing the remote infrastructure?

Show Answer

Correct Answer

A

Option A is correct because applying in refresh-only mode updates state to reflect the accepted change without modifying the remote object. Option B is not correct because a normal apply can change infrastructure to match configuration. Option C removes Terraform's tracking of the resource instead of recording its current attributes. Option D only creates a plan and does not persist the refreshed state.

7

Maintain infrastructure with Terraform

This topic covers importing existing infrastructure into Terraform and inspecting resource information with CLI state commands. Candidates must also know when to enable detailed Terraform logs and how to direct them to a file when diagnosing failures.

Question 19 of 24 Single Choice

A team has an EC2 instance that was created manually and must now be managed by Terraform. The AWS provider is configured, and the configuration contains a matching aws_instance.web resource block with the intended settings. The operator has confirmed the instance ID and wants to attach it to Terraform without creating another instance.

Which command should the operator run to associate the existing instance with the configured Terraform resource?

Show Answer

Correct Answer

B

Option B is correct because the resource block already defines aws_instance.web, and the import command takes its address followed by the existing instance ID. Option A is not correct because apply does not accept an address and ID as import arguments. Option C removes state tracking. Option D reverses the required import arguments.

Question 20 of 24 Single Choice

An operations engineer is investigating why an application is using an unexpected database endpoint. The state contains several database resources, including one created inside the database module. The engineer needs to read the attributes recorded for that one instance and must not alter state or print the entire state file.

Which command should the engineer use to inspect the stored attributes for this specific resource instance?

Show Answer

Correct Answer

A

Option A is correct because terraform state show displays the stored attributes for the addressed resource instance, including one nested in a module. Option B lists resource addresses but not their attributes. Option C outputs the complete raw state and does not accept a resource address. Option D displays state or a plan, but the address is not a filter for that command.

Question 21 of 24 Single Choice

A Linux-based operations team can initialize its working directory, but terraform plan repeatedly fails when the provider reads a remote API. The error message does not identify the failing request. The team needs detailed diagnostic output saved to a file for review, and its change-control rules prohibit applying changes during troubleshooting.

What is the best next diagnostic step for the failed plan?

Show Answer

Correct Answer

C

Option C is correct because TF_LOG enables diagnostic logging and TF_LOG_PATH directs the output to a file while the engineer reruns the failing plan. Option A sets only the destination, so logging is not enabled. Option B disables logging. Option D risks making infrastructure changes, while a plan is sufficient to reproduce the failure.

8

HCP Terraform

HCP Terraform provides hosted workspaces for running Terraform and features for teams to collaborate and apply governance controls. Candidates must be able to organize workspaces in projects, configure integrations, and select workspace settings that meet operational and access requirements.

Question 22 of 24 Single Choice

A company uses HCP Terraform to manage infrastructure in a cloud account. Some required services have private addresses and accept connections only from a controlled network. The security team prohibits inbound connections from HCP Terraform, but permits an internal host to initiate outbound connections. The workspace must continue to use HCP Terraform for its runs.

Which HCP Terraform configuration best meets the network requirement?

Show Answer

Correct Answer

A

Option A is correct because an agent in the private network can execute the workspace runs and reach the internal services without inbound access from HCP Terraform. Option B is not correct because remote execution does not provide network access to the isolated services. Option C is not correct because VCS connections trigger runs but do not provide private network connectivity. Option D is not correct because a variable cannot change where local execution runs.

Question 23 of 24 Single Choice

An organization has six HCP Terraform workspaces, three for staging and three for production. The same platform team administers both environments, but the application team must be able to manage staging runs and settings without access to production workspaces. The organization wants a clear grouping for each environment and does not want to duplicate organization-wide administration.

Which organization design best meets the team's access and separation requirements?

Show Answer

Correct Answer

B

Option B is correct because separate projects keep the environments grouped distinctly, and project access lets the application team manage only staging workspaces. Option A is not correct because broad project access would also expose production workspaces. Option C is not correct because variables do not control user permissions or isolate workspace access. Option D is not correct because separate organizations add unnecessary administrative separation for this requirement.

Question 24 of 24 Single Choice

A security team requires an external service to inspect every HCP Terraform plan before infrastructure changes can be applied. The service returns a pass or fail result, and a failed result must prevent the run from proceeding. The team wants the check to occur after a plan is available, rather than using a notification that only reports the run outcome.

Which HCP Terraform integration should the team configure to enforce this control?

Show Answer

Correct Answer

A

Option A is correct because a mandatory post-plan run task lets the scanner evaluate the generated plan and block the run when the task fails. Option B is not correct because notifications report events but do not enforce a policy gate. Option C is not correct because run triggers coordinate workspace runs rather than enforce scanner results. Option D is not correct because variables store values and do not invoke the scanner.

Continue Your Terraform-Associate-004 Preparation

You have seen 24 questions from a full set of 385. Prepare with the Terraform-Associate-004 dumps PDF and the Web-Based Practice Test.

PDF

  • Compatible with All Devices
  • Printable Format
  • No Download Limits

Practice Test

  • Check your timing and weak areas
  • No Practice Limits
  • Regularly Updated
Get Full Access
  • 100% Money-Back Guarantee
  • 90 Days Free Updates
  • Instant Access

Frequently Asked Questions

Why does Terraform state management challenge candidates on Terraform-Associate-004?

State is more than a record of resources. You need to understand how it connects Terraform resource addresses to remote objects, how locking protects state during changes, and what can happen when infrastructure drifts or state moves between backends. These concepts can be difficult to distinguish in scenario-based decisions. Practise explaining what a state operation changes before choosing a command, especially when preserving the relationship between Terraform and existing infrastructure.

How demanding is the 60-minute exam when questions involve workflow decisions?

The time limit makes it important to recognize the purpose and order of commands without having to reconstruct the workflow from scratch. You may need to distinguish formatting and validation from planning, applying, or removing infrastructure, then interpret a proposed change before acting. The Exam4Success Practice Test can help you check pacing and identify weak areas. After each attempt, review every workflow choice you hesitated over and write the correct command sequence from memory.

Why can Terraform configuration practice feel different from answering exam scenarios?

Writing a resource in a working configuration does not automatically prepare you to reason about variables, data sources, expressions, dependencies, or sensitive values in a new situation. The exam expects you to interpret how configuration elements connect and what their effects are. The Exam4Success PDF guide can support focused review when a lab is not available. Pair each topic review with a small exercise, such as tracing a module input to the output that consumes it.

What preparation mistake causes trouble with providers and modules?

Memorizing isolated configuration snippets can leave gaps when you must interpret provider installation and version selection, multiple provider configurations, or module source and version constraints. These choices depend on what the configuration requires, not just on syntax. Build a compact review file with one example of each pattern and annotate why its version or input choice fits. Then practise explaining the consequences of changing one constraint before moving to another topic.

What practical capability does Terraform-Associate-004 help candidates develop?

The exam focuses on using Infrastructure as Code to define and maintain infrastructure through consistent workflows across cloud platforms, hybrid environments, and services. Its topics also cover configuration, state, modules, and diagnosing failures, so preparation can help you reason more clearly about common Terraform tasks. It is most useful when you connect the concepts to work you expect to do. Choose a familiar infrastructure example and map its resources, inputs, outputs, and state relationship.

Why might someone responsible for team deployments value the HCP Terraform content?

HCP Terraform topics address hosted workspaces, team collaboration, and governance controls. Candidates are expected to understand workspace organization in projects, integrations, and settings that meet operational and access requirements. This knowledge is relevant when a team needs to coordinate Terraform runs rather than rely only on an individual working directory. To make the topic concrete, compare a workspace setting with the operational or access need it is intended to meet.

How can I tell if I am ready to move from Terraform basics to exam review?

You are ready to broaden your review when you can describe the core workflow and explain how resources, providers, and state relate, rather than only following a tutorial. Check whether you can also distinguish a data source from a resource and trace values through module inputs and outputs. Use the Exam4Success PDF guide to identify topics you have not reviewed, then test yourself by explaining one configuration and state scenario without referring to notes.

What should I study first if I have limited preparation time?

Start with the core workflow and Terraform fundamentals, since those concepts recur in configuration, state management, and infrastructure maintenance. Then review modules and HCP Terraform, including their inputs, outputs, version constraints, workspace organization, and access requirements. The exam is delivered online with proctoring, in English, and allows 60 minutes, so include timed practice after reviewing the concepts. Use a Practice Test to find the areas where you lose time, then direct your remaining review there.

Exam4Success is an independent exam preparation provider and is not affiliated with or endorsed by HashiCorp.