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

Page: 1 / 14
Total 359 questions
Question 1

You add a new resource to an existing Terraform configuration, but do not update the version constraint in the configuration. The existing and new resources use the same provider. The working contains a .terraform.lock, hc1 file.

How will Terraform choose which version of the provider to use?



Answer : A

This is how Terraform chooses which version of the provider to use, when you add a new resource to an existing Terraform configuration, but do not update the version constraint in the configuration. The lock file records the exact version of each provider that was installed in your working directory, and ensures that Terraform will always use the same provider versions until you runterraform init -upgradeto update them.


Question 2

Which of the following statements about Terraform modules is not true?



Answer : C

This is not true, as modules can be either public or private, depending on your needs and preferences. You can use the Terraform Registry to publish and consume public modules, or use Terraform Cloud or Terraform Enterprise to host and manage private modules.


Question 3

A child module can always access variables declared in its parent module.



Answer : B

Child modulesdo not automatically inheritvariables from the parent module.

To pass values from theparent moduleto thechild module, you mustexplicitly define input variablesin the child module and pass them in the parent module.

Example:

hcl

CopyEdit

module 'example' {

source = './child_module'

var1 = 'value'

}

Official Terraform Documentation Reference:

Passing Variables to Modules


Question 4

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 5

You have declared a variable called var.list which is a list of objects that all have an attribute id . Which options will produce a list of the IDs? Choose two correct answers.



Answer : B, C

These are two ways to produce a list of the IDs from a list of objects that have an attributeid, using either a for expression or a splat expression syntax.


Question 6

You can reference a resource created with for_each using a Splat ( *) expression.



Answer : B

You cannot reference a resource created withfor_eachusing a splat (*) expression, as it will not work with resources that have non-numeric keys. You need to use aforexpression instead to iterate over the resource instances.


Question 7

What is the workflow for deploying new infrastructure with Terraform?



Answer : A

This is the workflow for deploying new infrastructure with Terraform, as it will create a plan and apply it to the target environment. The other options are either incorrect or incomplete.


Page:    1 / 14   
Total 359 questions