HashiCorp Certified: Terraform Associate (004) (HCTA0-004) Questions and Answers
What is the workflow for deploying new infrastructure with Terraform?
You can configure Terraform to log to a file using the TF_LOG environment variable.
You add a new provider to your configuration and immediately run terraform apply in the CD using the local backend. Why does the apply fail?
What does state looking accomplish?
Module variable assignments are inherited from the parent module and you do not need to explicitly set them.
Exhibit.

You need to deploy resources into two different regions in the same Terraform configuration. To do this, you declare multiple provider configurations as shown in the Exhibit space on this page.
What meta-argument do you need to configure in a resource block to deploy the resource to the us-west-2 AWS region?
Terraform installs its providers during which phase?
How does Terraform determine dependencies between resources?
Only the user that generated a terraform plan may apply it.
Which type of block fetches or computes information for use elsewhere in a Terraform configuration?
A module can always refer to all variables declared in its parent module.
Which of the following can you do with terraform plan? (Pick 2 correct responses)
As a developer, you want to ensure your plugins are up to date with the latest versions. Which Terraform command should you use?
Outside of the required_providers block, Terraform configurations always refer to providers by their local names.
Which of these commands makes your code more human readable?
Which of the following locations can Terraform use as aprivate sourcefor modules?(Pick 2 correct responses)
Which of these actions are forbidden when the Terraform state file is locked? (Pick the 3 correct responses)
What information does the public Terraform Module Registry automatically expose about published modules?
You have to initialize a Terraform backend before it can be configured.
What does Terraform not reference when running a terraform apply -refresh-only ?
You can reference a resource created with for_each using a Splat ( *) expression.
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?
Running terraform fmt without any flags in a directory with Terraform configuration files will check the formatting of those files, but will never change their contents.
Which command doesnotcause Terraform to refresh its state?
The Terraform binary version and provider versions must match each other in a single configuration.
When you initialize Terraform, where does it cache modules from the public Terraform Registry?
What type of information can be found on the Terraform Registry when using published modules?
You used Terraform to create an ephemeral development environment in the cloud and are now ready to destroy all the infrastructure described by your Terraform configuration. To be safe, you would like to first see all the infrastructure that Terraform will delete.
Which command should you use to show all the resources that will be deleted? (Pick the 2 correct responses)
Why does this backend configuration not follow best practices?

You ate creating a Terraform configuration which needs to make use of multiple providers, one for AWS and one for Datadog. Which of the following provider blocks would allow you to do this?
A)

B)
C)
D)
You must use different Terraform commands depending on the cloud provider you use.
Which of the following statements about Terraform modules is not true?

A resource block is shown in the Exhibit space of this page. How would you reference the name value of the second instance of this resource?
What is the purpose of the terraform.lock.hcl file in Terraform?
Which parameters does terraform import require? Choose two correct answers.
Multiple team members are collaborating on infrastructure using Terraform and want to format the* Terraform code following standard Terraform-style convention.
How should they ensure the code satisfies conventions?
What is the name of the default file where Terraform stores the state?
Type your answer in the field provided. The text field is not case-sensitive and all variations of the correct answer are accepted.
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?
Which of these ate secure options for storing secrets for connecting to a Terraform remote backend? Choose two correct answers.
Only the user that generated a plan may apply it.
You have a Terraform configuration that defines a single virtual machine with no references to it, You have run terraform apply to create the resource, and then removed the resource definition from your Terraform configuration file.
What will happen you run terraform apply in the working directory again?
What is the provider for the resource shown in the Exhibit?
resource "aws_vpc" "main" {
name = "test"
}
Which configuration consistency errors does terraform validate report?
Using the terraform state rm command against a resource will destroy it.
Terraform providers are part of the Terraform core binary.
You cannot install third party plugins using terraform init.
You've used Terraform to deploy a virtual machine and a database. You want to replace this virtual machine instance with an identical one without affecting the database. What is the best way to achieve this using Terraform?
What does Terraform use the .terraform.lock.hc1 file for?
When you use a backend that requires authentication, it is best practice to:
What kind of configuration block will create an infrastructure object with settings specified within the block?
What is the Terraform style convention for indenting a nesting level compared to the one above it?
Where can Terraform not load a provider from?
You much initialize your working directory before running terraform validate.
Your security team scanned some Terraform workspaces and found secrets stored in plaintext in state files. How can you protect that data?
If one of your modules uses a local value, you can expose that value to callers of the module by defining a Terraform output in the module’s configuration.
Setting the TF_LOG environment variable to DEBUG causes debug messages to be logged into stdout.
Before you can use a new backend or HCP Terraform/Terraform Cloud integration, you must first execute terraform init.
Which task does terraform init not perform?
HashiCorp Configuration Language (HCL) supports user-denned functions.
Terraform can only manage resource dependencies if you set them explicitly with the depends_on argument.
When you include a module block in your configuration that references a module from the Terraform Registry, the "version" attribute is required.
terraform validate confirms the syntax of Terraform files.
Which are forbidden actions when the terraform state file is locked? Choose three correct answers.
You created infrastructure outside the Terraform workflow that you now want to manage using Terraform. Which command brings the infrastructure into Terraform state?
Your DevOps team is currently using the local backend for your Terraform configuration. You would like to move to a remote backend to store the state file in a central location. Which of the following backends would not work?
How could you reference an attribute from the vsphere_datacenter data source for use with the datacenter_id argument within the vsphere_folder resource in the following configuration?
Which Terraform command checks that your configuration syntax is correct?
Module version is required to reference a module on the Terraform Module Registry.
Which of these actions will prevent two Terraform runs from changing the same state file at the same time?
You want to use API tokens and other secrets within your team's Terraform workspaces. Where does HashiCorp recommend you store these sensitive values? (Pick the 3 correct responses)
What does the default "local" Terraform backend store?
A Terraform output that sets the "sensitive" argument to true will not store that value in the state file.
What is the provider for this resource?

Which of the following is not an action performed by terraform init?
If you manually destroy infrastructure, what is the best practice reflecting this change in Terraform?
How does the Terraform cloud integration differ from other state backends such as S3, Consul,etc?
When should you run terraform init?