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

Page: 1 / 14
Total 359 questions
Question 1

Your configuration contains a module block that references a module from the Terraform Registry and sets the version argument to 1.0. You just published a new version of the module and updated your configuration to point to version 1.1.

Which command must be run to install the new version?



Answer : A

Detailed

Rationale for Correct Answe r: terraform init installs and updates modules used by a Terraform configuration. After changing a module version constraint or version number, you must run terraform init so Terraform downloads the selected module version.

Analysis of Incorrect Options (Distractors):

B . terraform modules. Incorrect. There is no standard Terraform CLI command named terraform modules.

C . terraform plan. Incorrect. plan creates an execution plan but does not install updated module packages.

D . terraform apply. Incorrect. apply applies planned infrastructure changes, but module installation must be handled during initialization first.

Key Concept: Terraform modules are installed and updated during initialization.


Question 2

You have never used Terraform before and would like to test it out using a shared team account for a cloud provider. The shared team account already contains 15 virtual machines (VM). You develop a Terraform configuration containing one VM. perform terraform apply, and see that your VM was created successfully. What should you do to delete the newly-created VM with Terraform?



Answer : C

This is the best way to delete the newly-created VM with Terraform, as it will only affect the resource that was created by your configuration and state file. The other options are either incorrect or inefficient.


Question 3

terraform init creates an example main.tf file in the current directory.



Answer : B

terraform initdoes not create a main.tf file.

Itinitializesthe Terraform working directory, downloads provider plugins, and configures the backend.

Terraform does not generate an example configuration (main.tf); users must create it manually.

Official Terraform Documentation Reference:

terraform init - HashiCorp Documentation


Question 4

You've just finished refactoring part of your Terraform workspace's configuration to use a module to manage some of your resources. When you plan your changes, you notice that Terraform will destroy and recreate the affected resources. Doing so could cause unintended downtime in the application your workspace manages. What supported approach should you take to complete the refactor without destroying and recreating your resources?



Answer : A

Detailed

Rationale for Correct Answe r:Refactoring (like moving resources into a module) changes resource addresses. Terraform will plan destroy/create unless it knows the resources were moved. The supported mechanism is a moved block, which tells Terraform how to map the old address to the new address so it updates state without recreating resources.

Analysis of Incorrect Options (Distractors):

B: Incorrect. terraform console is for evaluating expressions and inspecting values; it is not a supported state editor.

C: Incorrect. Manually editing terraform.tfstate is unsafe and not the recommended/supported approach (risk of corruption and subtle errors).

D: Incorrect. Renaming resources in a cloud console does not update Terraform state addresses and usually doesn't solve Terraform address refactors.

Key Concept:State-aware refactoring using moved blocks to preserve resources while changing their addresses.


Question 5

Which two steps are required to provision new infrastructure in the Terraform workflow? Choose two correct answers.



Answer : D, E

The two steps that are required to provision new infrastructure in the Terraform workflow areinitandapply. Theterraform initcommand initializes a working directory containing Terraform configuration files. It downloads and installs the provider plugins that are needed for the configuration, and prepares the backend for storing the state. Theterraform applycommand applies the changes required to reach the desired state of the configuration, as described by the resource definitions in the configuration files. It shows a plan of the proposed changes and asks for confirmation before making any changes to the infrastructure.Reference= [The Core Terraform Workflow], [Initialize a Terraform working directory with init], [Apply Terraform Configuration with apply]


Question 6

When you use a remote backend that needs authentication, HashiCorp recommends that you:



Answer : D

This is the recommended way to use a remote backend that needs authentication, as it allows you to provide the credentials via environment variables, command-line arguments, or interactive prompts, without storing them in the Terraform configuration files.


Question 7

Module version is required to reference a module on the Terraform Module Registry.



Answer : B

Module version is optional to reference a module on the Terraform Module Registry.If you omit the version constraint, Terraform will automatically use the latest available version of the module


Page:    1 / 14   
Total 359 questions