| Exam Code | Terraform-Associate-004 |
| Exam Name | HashiCorp Certified: Terraform Associate (004) (HCTA0-004) |
| Vendor | HashiCorp |
| Total Questions | 301 |
| Last Updated | 26-Oct, 2026 |
- Latest & Verified Questions
- Detailed Explanations
- Regular Updates
- Full-Length Practice Tests
- Boost Your Exam Confidence
PDF Study Materials
Downloadable guides and resources
Practice Tests
Full-length tests with real exam experience
Progress Tracking
Monitor your performance and improvement
Study Anywhere
Access on desktop, tablet, and mobile
Free Terraform-Associate-004 Practice Questions
Explore 10 free practice questions for the HashiCorp Terraform-Associate-004 exam and review the answers and explanations to support your preparation.
-
Question 1
Single answerYour team uses HCP Terraform to manage infrastructure. You need to make a change to an infrastructure stack running in a public cloud.
Which pattern follows Infrastructure as Code best practices for making the change?
-
Option A:Correct
Clone the repository containing your infrastructure code, and then run the code.
-
Option B:Correct
Use the public cloud console to make the change.
-
Option C:Correct
Make the change through the public cloud API endpoint.
-
Option D:Correct
Run the public cloud CLI tool to make the change
-
Option E:Correct
Submit a pull request and wait for an approved merge of the change.
Show Answer & Explanation Hide Answer & Explanation
Correct Answer: E
Explanation
Detailed Explanation:
Rationale for Correct Answer: Infrastructure as Code best practice is to make infrastructure changes through version-controlled configuration. With HCP Terraform, a common and recommended workflow is to modify Terraform code in a branch, submit a pull request, review and approve the change, merge it, and let HCP Terraform execute the run based on that VCS-driven workflow. This preserves review history, auditability, collaboration, and consistency.
Analysis of Incorrect Options (Distractors):
A. Clone the repository containing your infrastructure code, and then run the code. Incorrect. Running locally can bypass centralized HCP Terraform workflow controls, policy checks, approvals, and audit trails.
B. Use the public cloud console to make the change. Incorrect. Console changes create configuration drift and bypass Terraform state and version control.
C. Make the change through the public cloud API endpoint. Incorrect. Direct API changes bypass Terraform and can cause drift.
D. Run the public cloud CLI tool to make the change. Incorrect. Cloud CLI changes are imperative changes outside Terraform’s managed workflow.
Key Concept: Infrastructure changes should be made through version-controlled Terraform configuration and reviewed before being applied.
[Reference: Terraform Objective Domain: Understand Infrastructure as Code (IaC) Concepts,
-
-
Question 2
Single answerWhich of these is true about Terraform ' s plugin-based architecture?
-
Option A:Correct
Terraform can only source providers from the internet
-
Option B:Correct
Every provider in a configuration has its own state file for its resources
-
Option C:Correct
You can create a provider for your API if none exists
-
Option D:Correct
All providers are part of the Terraform core binary
Show Answer & Explanation Hide Answer & Explanation
Correct Answer: C
Explanation
Terraform is built on a plugin-based architecture, enabling developers to extend Terraform by writing new plugins or compiling modified versions of existing plugins1.
Terraform plugins are executable binaries written in Go that expose an implementation for a specific service, such as a cloud resource, SaaS platform, or API2. If there is
no existing provider for your API, you can create one using the Terraform Plugin SDK3 or the Terraform Plugin Framework4. References =
•1: Plugin Development - How Terraform Works With Plugins | Terraform | HashiCorp Developer
•2: Lab: Terraform Plug-in Based Architecture - GitHub
•3: Terraform Plugin SDK - Terraform by HashiCorp
•4: HashiCorp Terraform Plugin Framework Now Generally Available
-
-
Question 3
Single answerWhat does state looking accomplish?
-
Option A:Correct
Prevent accidental Prevent accident deletion of the state file
-
Option B:Correct
Blocks Terraform commands from modifying, the state file
-
Option C:Correct
Copies the state file from memory to disk
-
Option D:Correct
Encrypts any credentials stored within the state file
Show Answer & Explanation Hide Answer & Explanation
Correct Answer: B
Explanation
This is what state locking accomplishes, by preventing other users from modifying the state file while a
Terraform operation is in progress. This prevents conflicts and data loss.
-
-
Question 4
True / FalseTerraform providers are part of the Terraform core binary.
-
Option A: TrueCorrect
-
Option B: FalseCorrect
Show Answer & Explanation Hide Answer & Explanation
Correct Answer: A
Explanation
Rationale for Correct Answer (True):
A cloud block in Terraform configuration specifies a single Terraform Cloud or HCP Terraform workspace. You cannot use one cloud block for multiple workspaces.
Analysis of Incorrect Option:
False: Incorrect because a cloud block is a one-to-one mapping with a single workspace.
Key Concept:
Cloud blocks manage remote operations and backend configuration tied to one workspace.
[Reference:Terraform Exam Objective – Manage Terraform Workspaces and Cloud., , , , , ]
-
-
Question 5
True / FalseBefore you can use a remote backend, you must first execute terra-form init.
-
Option A: TrueCorrect
-
Option B: FalseCorrect
Show Answer & Explanation Hide Answer & Explanation
Correct Answer: A
Explanation
Before using a remote backend in Terraform, it is mandatory to run terraform init. This command initializes a Terraform working directory, which includes configuring the backend. If a remote backend is specified, terraform init will set up the working directory to use it, including copying any existing state to the remote backend if necessary.References = This principle is a fundamental part of workingwith Terraform and its backends, as outlined in general Terraform documentation and best practices. The specific HashiCorp Terraform Associate (003) study materials in the provided files did not include direct references to this information
-
-
Question 6
Single answerYour team adopts AWS CloudFormation as the standardized method for provisioning public cloud resources.
Which scenario presents a challenge for your team?
-
Option A:Correct
Building a reusable codebase that can deploy resources into any AWS region.
-
Option B:Correct
Managing a new application stack built on AWS-native services.
-
Option C:Correct
Deploying new infrastructure into Microsoft Azure.
-
Option D:Correct
Show Answer & Explanation Hide Answer & Explanation
Correct Answer: C
Explanation
Detailed Explanation:
Rationale for Correct Answer: AWS CloudFormation is a service specifically designed to provision and manage infrastructure within AWS only. It does not support multi-cloud environments such as Microsoft Azure. Therefore, attempting to deploy infrastructure into Azure using CloudFormation presents a clear limitation and challenge. This aligns with Terraform’s core value proposition: multi-cloud and provider-agnostic infrastructure management, which overcomes this limitation.
Analysis of Incorrect Options (Distractors):
A. Building a reusable codebase that can deploy resources into any AWS region. Incorrect because CloudFormation supports reusable templates and can deploy across AWS regions without issue.
B. Managing a new application stack built on AWS-native services. Incorrect because CloudFormation is purpose-built for AWS-native services and handles this scenario effectively.
D. Automating a manual, web console-based provisioning process. Incorrect because CloudFormation is specifically designed to automate infrastructure provisioning, replacing manual console operations.
Key Concept: Cloud-specific vs multi-cloud Infrastructure as Code tools — Terraform supports multiple providers, whereas CloudFormation is AWS-only.
[Reference: Terraform Objective Domain: Understand Terraform's Purpose and Use Cases, , , , , , ] -
-
Question 7
True / FalseRunning terraform fmt without any flags in a directory with Terraform configuration files check the formatting of those files without changing their contents.
-
Option A: TrueCorrect
-
Option B: FalseCorrect
Show Answer & Explanation Hide Answer & Explanation
Correct Answer: B
Explanation
Running terraform fmt without any flags in a directory with Terraform configuration files will not check the formatting of those files without changing their contents, but will actually rewrite them to a canonical format and style. If you want to check the formatting without making changes, you need to use the -check flag.
-
-
Question 8
Single answerA resource block is shown in the Exhibit space of this page. How would you reference the name value of the second instance of this resource?
-
Option A:Correct
aws_instance.web[2].name
-
Option B:Correct
aws_instance.web.*.name
-
Option C:Correct
aws_instance.web[l].name
-
Option D:Correct
aws_instance.web[l]
-
Option E:Correct
Show Answer & Explanation Hide Answer & Explanation
Correct Answer: C
Explanation
Rationale for Correct Answer:When using count, Terraform creates resources indexed starting at 0.With count = 2, the instances are indexed as:
First instance → aws_instance.web[0]
Second instance → aws_instance.web[1]
To reference the name attribute of the second instance, the correct syntax is:
aws_instance.web[1].name
Analysis of Incorrect Options (Distractors):
A. [2]: Incorrect because indexing starts at 0 and only indices 0 and 1 exist.
B. *.name: Returns a list of all names, not a single instance value.
D. [1]: References the whole resource object, not the name attribute.
E. element(...): Incorrect syntax and wrong index; also unnecessary when direct indexing is available.
Key Concept:Understanding resource indexing with count and zero-based indexing in Terraform.
[Reference:Terraform Exam Objective – Read, Generate, and Modify Configurations, , , , , ] -
-
Question 9
Single answerWhich of the following should you put into the required_providers block?
-
Option A:Correct
version > = 3.1
-
Option B:Correct
version = “ > = 3.1”
-
Option C:Correct
Show Answer & Explanation Hide Answer & Explanation
Correct Answer: B
Explanation
The required_providers block is used to specify the provider versions that the configuration can work with. The version argument accepts a version constraint string, which must be enclosed in double quotes. The version constraint string can use operators such as > =, ~ > , =, etc. to specify the minimum, maximum, or exact version of the provider. For example, version = " > = 3.1 " means that theconfiguration can work with any provider version that is 3.1 or higher. References = [Provider Requirements] and [Version Constraints]
-
-
Question 10
True / FalseYou can configure Terraform to log to a file using the TF_LOG environment variable.
-
Option A: TrueCorrect
-
Option B: FalseCorrect
Show Answer & Explanation Hide Answer & Explanation
Correct Answer: A
Explanation
You can configure Terraform to log to a file using the TF_LOG environment variable. This variable can be set to one of the log levels: TRACE, DEBUG, INFO, WARN or ERROR. You can also use the TF_LOG_PATH environment variable to specify a custom log file location. References = : Debugging Terraform
-