Free Terraform Associate Sample Questions — HashiCorp Certified: Terraform Associate

Free Terraform Associate sample questions for the HashiCorp Certified: Terraform Associate exam. No account required: study at your own pace.

Want an interactive quiz? Take the full Terraform Associate practice test

Looking for more? Click here to get the full PDF with 320+ practice questions for $10 for offline study and deeper preparation.

Question 1

You have some Terraform code and a variable definitions file named dev.auto.tfvars that you tested successfully in the dev environment. You want to deploy the same code in the staging environment with a separate variable definition file and a separate state file. Which two actions should you perform? (Choose two.)

  • A. Copy the existing terraform.tfstate file and save it as staging.terraform.tfstate
  • B. Write a new staging.auto.tfvars variable definition file and run Terraform with the var-file=”staging.auto.tfvars” flag
  • C. Create a new Terraform workspace for staging
  • D. Create a new Terraform provider for staging
  • E. Add new Terraform code (*.tf files) for staging in the same directory
Show Answer
Correct Answer:
  • B. Write a new staging.auto.tfvars variable definition file and run Terraform with the var-file=”staging.auto.tfvars” flag
  • C. Create a new Terraform workspace for staging
Question 2

You add a new provider to your configuration and immediately run terraform apply in the CLI using the local backend. Why does the apply fail?

  • A. Terraform needs you to format your code according to best practices first
  • B. Terraform requires you to manually run terraform plan first
  • C. The Terraform CLI needs you to log into Terraform Cloud first
  • D. Terraform needs to install the necessary plugins first
Show Answer
Correct Answer:
D. Terraform needs to install the necessary plugins first
Question 3

Which of the following is not an action performed by terraform init?

  • A. Create template configuration files
  • B. Initialize a configured backend
  • C. Retrieve the source code for all referenced modules
  • D. Load required provider plugins
Show Answer
Correct Answer:
A. Create template configuration files
Question 4

Your DevOps team is currently using the local backend for your Terraform configuration. You would like to move to a remote backend to begin storing the state file in a central location. Which of the following backends would not work?

  • A. Amazon S3
  • B. Artifactory
  • C. Git
  • D. Terraform Cloud
Show Answer
Correct Answer:
C. Git
Question 5

When does Sentinel enforce policy logic during a Terraform Cloud run?

  • A. Before the plan phase
  • B. During the plan phase
  • C. Before the apply phase
  • D. After the apply phase
Show Answer
Correct Answer:
C. Before the apply phase
Question 6

A senior admin accidentally deleted some of your cloud instances. What does Terraform do when you run terraform apply?

  • A. Build a completely brand new set of infrastructure
  • B. Tear down the entire workspace infrastructure and rebuild it
  • C. Rebuild only the instances that were deleted
  • D. Stop and generate an error message about the missing instances
Show Answer
Correct Answer:
C. Rebuild only the instances that were deleted
Question 7

Which of the following is the correct way to pass the value in the variable num_servers into a module with the input servers in HCL2?

  • A. servers - var.num_servers
  • B. servers - num_servers
  • C. servers - var(num_servers)
  • D. $(var.num_servers)
Show Answer
Correct Answer:
A. servers - var.num_servers
Question 8

Terraform can import modules from a number of sources `" which of the following is not a valid source?

  • A. FTP server
  • B. GitHub repository
  • C. Local path
  • D. Terraform Module Registry
Show Answer
Correct Answer:
A. FTP server
Question 9

When should you use the force-unlock command?

  • A. You see a status message that you cannot acquire the lock
  • B. You have a high priority change
  • C. Automatic unlocking failed
  • D. You apply failed due to a state lock
Show Answer
Correct Answer:
C. Automatic unlocking failed
Question 10

A Terraform provider is not responsible for:

  • A. Understanding API interactions with some service
  • B. Provisioning infrastructure in multiple clouds
  • C. Exposing resources and data sources based on an API
  • D. Managing actions to take based on resource differences
Show Answer
Correct Answer:
D. Managing actions to take based on resource differences
Question 11

A developer accidentally launched a VM (virtual machine) outside of the Terraform workflow and ended up with two servers with the same name. They don’t know which VM Terraform manages but do have a list of all active VM IDs. Which of the following methods could you use to discover which instance Terraform manages?

  • A. Run terraform taint/code on all the VMs to recreate them
  • B. Update the code to include outputs for the ID of all VMs, then run terraform plan to view the outputs
  • C. Run terraform state list to find the names of all VMs, then run terraform state show for each of them to find which VM ID Terraform manages
  • D. Use terraform refresh/code to find out which IDs are already part of state
Show Answer
Correct Answer:
C. Run terraform state list to find the names of all VMs, then run terraform state show for each of them to find which VM ID Terraform manages
Question 12

You have deployed a new webapp with a public IP address on a cloud provider. However, you did not create any outputs for your code. What is the best method to quickly find the IP address of the resource you deployed?

  • A. Run terraform output ip_address to view the result
  • B. In a new folder, use the terraform_remote_state data source to load in the state file, then write an output for each resource that you find the state file
  • C. Run terraform state list to find the name of the resource, then terraform state show to find the attributes including public IP address
  • D. Run terraform destroy then terraform apply and look for the IP address in stdout
Show Answer
Correct Answer:
C. Run terraform state list to find the name of the resource, then terraform state show to find the attributes including public IP address
Question 13

How is terraform import run?

  • A. As a part of terraform init
  • B. As a part of terraform plan
  • C. As a part of terraform refresh
  • D. By an explicit call
  • E. All of the above
Show Answer
Correct Answer:
D. By an explicit call
Question 14

Module variable assignments are inherited from the parent module and do not need to be explicitly set.

  • A. True
  • B. False
Show Answer
Correct Answer:
B. False
Question 15

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 directory contains a .terraform-lock.hcl file. How will Terraform choose which version of the provider to use?

  • A. Terraform will use the latest version of the provider for the new resource and the version recorded in the lock file to manage existing resources
  • B. Terraform will use the version recorded in your lock file
  • C. Terraform will check your state file to determine the provider version to use
  • D. Terraform will use the latest version of the provider available at the time you provision your new resource
Show Answer
Correct Answer:
B. Terraform will use the version recorded in your lock file
Question 16

Which of these is not a benefit of remote state?

  • A. Keeping unencrypted sensitive information off disk
  • B. Easily share reusable code modules
  • C. Working in a team
  • D. Delegate output to other teams
Show Answer
Correct Answer:
B. Easily share reusable code modules
Question 17

The terraform.tfstate file always matches your currently built infrastructure.

  • A. True
  • B. False
Show Answer
Correct Answer:
B. False
Question 18

What features stops multiple users from operating on the Terraform state at the same time?

  • A. Provider constraints
  • B. Remote backends
  • C. State locking
  • D. Version control
Show Answer
Correct Answer:
C. State locking
Question 19

Which type of block fetches or computes information for use elsewhere in a Terraform configuration?

  • A. provider
  • B. resource
  • C. local
  • D. data
Show Answer
Correct Answer:
D. data
Question 20

Which backend does the Terraform CLI use by default?

  • A. Terraform Cloud
  • B. Consul
  • C. Remote
  • D. Local
Show Answer
Correct Answer:
D. Local

Aced these? Get the Full Exam

Download the complete Terraform Associate study bundle with 320+ questions in a single printable PDF.