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

Page: 1 / 14
Total 301 questions
Question 1

Which task does terraform init not perform?



Answer : B

Rationale for Correct Answer: terraform init initializes the working directory: it sets up the backend, downloads providers, and installs modules. It does not validate that required input variables have values---that check occurs when running commands that evaluate the configuration (typically plan/apply), and terraform validate checks configuration structure, not whether you supplied runtime variable values.

Analysis of Incorrect Options (Distractors):

A: Yes---init installs required providers.

C: Yes---init initializes and configures the backend.

D: Yes---init retrieves and installs modules referenced by module blocks.

Key Concept: What terraform init does vs what happens at plan/apply time.


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

Question 2

Define the purpose of state in Terraform.



Answer : A

The purpose of state in Terraform is to keep track of the real-world resources managed by Terraform, mapping them to the configuration. The state file contains metadata about these resources, such as resource IDs and other important attributes, which Terraform uses to plan and manage infrastructure changes. The state enables Terraform to know what resources are managed by which configurations and helps in maintaining the desired state of the infrastructure.Reference = This role of state in Terraform is outlined in Terraform's official documentation, emphasizing its function in mapping configuration to real-world resources and storing vital metadata .


Question 3

Before you can use a new backend or HCP Terraform/Terraform Cloud integration, you must first execute terraform init.



Answer : A

The terraform init command is required before using a new backend or integrating with HCP Terraform/Terraform Cloud.

terraform init initializes the working directory and sets up the backend, downloading necessary provider plugins and modules.

If the backend configuration changes, Terraform willrequirere-initialization to apply those changes.

Without running terraform init, Terraform willfailto use a new backend or remote Terraform Cloud workspace.

Official Terraform Documentation Reference:

terraform init - HashiCorp Documentation


Question 4

How would you output returned values from a child module in the Terraform CLI output?



Answer : C

To output returned values from a child module in the Terraform CLI output, you need to declare the output in both the child module and the root module. The child module output will return the value to the root module, and the root module output will display the value in the CLI.Reference= [Terraform Outputs]


Question 5

Exhibit:

data "vsphere_datacenter" "dc" {}

resource "vsphere_folder" "parent" {

path = "Production"

type = "vm"

datacenter_id = _________

}

You want to pass the id of the vsphere_datacenter data source to the datacenter_id argument of the vsphere_folder resource. Which reference would you use?



Answer : A

Rationale for Correct Answer: Data sources are referenced with: data.<TYPE>.<NAME>.<ATTRIBUTE>.For a vSphere datacenter data source, the correct reference to its id is:data.vsphere_datacenter.<name>.id. Given the options, only A follows the correct data-source addressing pattern and includes the .id attribute.

Analysis of Incorrect Options (Distractors):

B: Incorrect---missing the data. prefix, so it looks like a managed resource reference.

C: Incorrect---missing the attribute (.id).

D: Incorrect---missing the data source type and name.

Key Concept: Correct HCL reference syntax for data sources.


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

Question 6

Which of the following does terraform apply change after you approve the execution plan? (Choose two.)



Answer : A, D

Theterraform applycommand changes both the cloud infrastructure and the state file after you approve the execution plan. The command creates, updates, or destroys the infrastructure resources to match theconfiguration. It also updates the state file to reflect the new state of the infrastructure. The.terraformdirectory, the execution plan, and the Terraform code are not changed by theterraform applycommand.Reference=Command: applyandPurpose of Terraform State


Question 7

Where can Terraform not load a provider from?



Answer : D

This is where Terraform cannot load a provider from, as it requires a compiled binary file that implements the provider protocol. You can load a provider from a plugins directory, a provider plugin cache, or the official HashiCorp distribution on releases.hashicorp.com.


Page:    1 / 14   
Total 301 questions