HashiCorp Terraform-Associate-003 HashiCorp Certified: Terraform Associate (003) Exam Practice Test

Page: 1 / 14
Total 228 questions
Question 1

Which of the following is true about terraform apply? (Pick 2 correct responses)



Answer : C, E

Comprehensive and Detailed in-Depth

C ( Correct) -- If changes require a resource replacement (e.g., changing an immutable attribute like instance type), Terraform will destroy and recreate the resource.

E ( Correct) -- Terraform only applies the configuration in the current directory or workspace.

Incorrect Answers:

A ( Incorrect) -- terraform apply can run without explicitly passing a plan.

B ( Incorrect) -- terraform apply automatically refreshes state before making changes.

D ( Incorrect) -- Terraform can target specific resources using -target.

Official Terraform Documentation Reference:


Question 2

You have just developed a new Terraform configuration for two virtual machines with a cloud provider. You would like to create the infrastructure for the first time.

Which Terraform command should you run first?



Answer : B

Comprehensive and Detailed in-Depth

B (terraform init) -- Must be run first to initialize the Terraform working directory, download providers, and configure the backend.

A (terraform apply) -- Requires initialization first, so it cannot be run before terraform init.

C (terraform plan) -- Also requires terraform init first to generate a plan.

D (terraform show) -- Displays the state, not relevant for first-time deployment.

Official Terraform Documentation Reference:


Question 3

What functionality do providers offer in Terraform? (Pick 3 correct responses)



Answer : A, B, D

Comprehensive and Detailed in-Depth

A ( Correct) -- Providers allow Terraform to interact with APIs of cloud/on-premises services.

B ( Correct) -- Some Terraform providers can provision on-premises infrastructure, such as VMware, OpenStack, etc.

C ( Incorrect) -- This describes Terraform Workspaces, not providers.

D ( Correct) -- Terraform providers allow provisioning of public cloud resources (AWS, Azure, GCP, etc.).

E ( Incorrect) -- Enforcing security and compliance policies is not a direct provider function, but it can be done using Sentinel or other policy-as-code tools.

Official Terraform Documentation Reference:


Question 4

Which command does not cause Terraform to refresh its state?



Answer : A

Comprehensive and Detailed in-Depth

terraform state list only displays resources stored in the state file but does not interact with the cloud provider or refresh the state.

terraform plan, terraform apply, and terraform destroy compare or modify the infrastructure, so they refresh the state to ensure accuracy.

Official Terraform Documentation Reference:

terraform state list - HashiCorp Documentation


Question 5

terraform init retrieves and caches the configuration for all remote modules.



Answer : B

Comprehensive and Detailed in-Depth

terraform init retrieves and caches providers and modules, but only for explicitly declared modules in the configuration.

If a module is added or updated, terraform init needs to be re-run to download the new version.

Terraform does not automatically cache all remote modules unless they are explicitly referenced in the configuration.

Official Terraform Documentation Reference:

terraform init - HashiCorp Documentation


Question 6

You just upgraded the version of a provider in an existing Terraform project. What do you need to do to install the new provider?



Answer : B

Comprehensive and Detailed in-Depth

When upgrading a provider, you must run terraform init -upgrade to install the new version.

This downloads the latest provider version and updates the local dependency cache.

terraform refresh (A) only updates the state file but does not upgrade providers.

terraform apply -upgrade (C) is not a valid command.

terraform version can be upgraded separately, but (D) does not install a new provider version.

Official Terraform Documentation Reference:


Question 7

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



Answer : B

Comprehensive and Detailed in-Depth

Child modules do not automatically inherit variables from the parent module.

To pass values from the parent module to the child module, you must explicitly define input variables in the child module and pass them in the parent module.

Example:

hcl

CopyEdit

module 'example' {

source = './child_module'

var1 = 'value'

}

Official Terraform Documentation Reference:


Page:    1 / 14   
Total 228 questions