HashiCorp Certified: Terraform Associate (004) Terraform-Associate-004 HCTA0-004 Exam Questions

Page: 1 / 14
Total 385 questions
Question 1

INcheck block's assertion fails, Terraform blocks the current operation from executing.



Answer : B

D

Rationale for Correct Answe r:A check block in Terraform is used to validate conditions and provide warnings or errors, but it does not block the execution of the operation by default. Failed checks will report issues, but Terraform continues execution unless explicitly configured otherwise. Therefore, the statement is false.

Analysis of Incorrect Options (Distractors):

A . True --- Incorrect because checkwith*

Key Concept:Check blocks are used for validation and observability but do not enforce execution blocking like preconditions or postconditions.


Question 2

Exhibit:

module "web_stack" {

source = "./modules/web_stack"

}

Your configuration defines the module block shown in the exhibit. The web_stack module accepts an input variable named servers. Which of the following changes to the module block sets the servers variable to the value of 3?



Answer : C

Detailed

Rationale for Correct Answe r:Module input variables are set by providing arguments in the module block whose names match the module's declared variables. Since the module expects servers, you pass it directly as servers = 3. This is the standard Terraform module input pattern.

Analysis of Incorrect Options (Distractors):

A: Incorrect. var.servers is how you reference an input variable in expressions, not how you assign a module input. Module inputs are set as arguments, not through the var. namespace.

B: Incorrect. Terraform module blocks do not use an inputs = { ... } argument (that pattern is common in some other tools, but not Terraform).

D: Incorrect. inputs.servers is not valid HCL syntax for setting module input arguments.

Key Concept:Passing input variables to modules by setting arguments on the module block.


Question 3

After creating a new Terraform configuration, your configuration passes terraform validate but returns an ''Access Denied'' error from the cloud provider when running terraform plan.

Why did terraform validate not catch this issue?



Answer : C

Detailed

Rationale for Correct Answe r: terraform validate checks Terraform configuration syntax and internal consistency. It does not authenticate to cloud providers, query provider APIs, verify permissions, or detect access-related provider errors. Provider access checks occur during commands such as terraform plan or terraform apply.

Analysis of Incorrect Options (Distractors):

A . Variables are only applied and validated during terraform plan, so terraform validate assumed defaults and returned a success message. Incorrect. Variable validation can be checked by terraform validate, but the issue here is provider authorization, not variable validation.

B . The working directory was not initialized, so the cloud provider plugin was unavailable when running the terraform validate command. Incorrect. If initialization were required and missing, Terraform would generally report an initialization-related error, not silently validate provider credentials.

D . The remote backend was not configured, so terraform validate could not load the state and detect the missing credentials. Incorrect. terraform validate does not need state to validate basic configuration syntax and consistency.

Key Concept: terraform validate does not contact provider APIs or verify cloud permissions.


Question 4

The_________determines how Terraform creates, updates, or delete resources.



Answer : C

This is what determines how Terraform creates, updates, or deletes resources, as it is responsible for understanding API interactions with some service and exposing resources and data sources based on that API.


Question 5

Which argument can you set on a module block to prevent Terraform from updating the module's configuration during an init or get operation?



Answer : A

Rationale for Correct Answer: Setting the module version (for registry modules) pins the module release Terraform will use. By pinning the version, Terraform will not ''update'' the module to newer releases during terraform init -upgrade or terraform get -update unless you change the version constraint. This is the standard way to control module updates and keep module code stable across runs.

Analysis of Incorrect Options (Distractors):

B (lifecycle): lifecycle is for resources, not module blocks.

C (count): count controls how many module instances are created; it doesn't control module source updates.

D (source): source tells Terraform where the module comes from; it doesn't prevent updates by itself (a VCS/ref pin would be done in the source string, but the module block argument that achieves this in the typical module workflow is version for registry modules).

Key Concept: Module version pinning to control module upgrades.


====================

Question 6

Terraform providers are part of the Terraform core binary.



Answer : B

Terraform providers are not part of the Terraform core binary. Providers are distributed separately from Terraform itself and have their own release cadence and version numbers. Providers are plugins that Terraform uses to interact with various APIs, such as cloud providers, SaaS providers, and other services. You can find and install providers from the Terraform Registry, which hosts providers for most major infrastructure platforms. You can also load providers from a local mirror or cache, or develop your own custom providers. To use a provider in your Terraform configuration, you need to declare it in the provider requirements block and optionally configure its settings in the provider block.Reference= :Providers - Configuration Language | Terraform:Terraform Registry - Providers Overview | Terraform


Question 7

Where does HashiCorp recommend you store API tokens and other secrets within your team's Terraform workspaces?

Pick the three correct responses below.



Answer : B, D, E

Detailed

Rationale for Correct Answe r:

B: HashiCorp Vault is designed for securely storing and dynamically generating secrets, with access controls and auditing.

D: Using environment variables (including TF_VAR_... for input variables) avoids committing secrets to code and works well in CI/CD.

E: HCP Terraform sensitive variables (workspace variables marked sensitive) are a recommended way to store secrets for runs in HCP Terraform without exposing them in the UI or logs (they are masked).

Analysis of Incorrect Options (Distractors):

A: Incorrect. Plaintext on a shared drive is insecure and lacks access control/auditing best practices.

C: Incorrect. Committing secrets to version control is strongly discouraged; even private repos can leak, and history is hard to scrub.

Key Concept:Secrets management best practices in Terraform workflows: keep secrets out of code and VCS; use Vault, HCP Terraform sensitive vars, or environment variables.


Page:    1 / 14   
Total 385 questions