HashiCorp Certified: Terraform Associate (004) (HCTA0-004) Questions and Answers
Parent modules can always access a child module’s variable values.
Terraform installs its providers during which phase?
terraform destroy is the only way to remove infrastructure.
What is the purpose of state locking in a remote backend?
When using Terraform to deploy resources into Azure, which scenarios are true regarding state files? (Choose two.)
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?
How can you trigger a run in a Terraform Cloud workspace that is connected to a Version Control System (VCS) repository?
You’ve updated your Terraform configuration, and you need to preview the proposed changes to your infrastructure. Which command should you run?
You can configure multiple cloud blocks in your Terraform configuration to connect your workspace to both HCP Terraform and your Terraform Enterprise instance.
Which are benefits of migrating from a local state backend to a remote backend? (Pick the 2 correct responses below.)
Which of the following does terraform apply change after you approve the execution plan? (Choose two.)
A module can always refer to all variables declared in its parent module.
If you manually destroy infrastructure, what is the best practice reflecting this change in Terraform?
Module version is required to reference a module on the Terraform Module Registry.
Where can Terraform not load a provider from?
What functionality do providers offer in Terraform? (Pick the 3 correct responses below.)
Which of these are features of Terraform Cloud? Choose two correct answers.
Which provider authentication method prevents credentials from being stored in the state file?
What does Terraform use to deploy infrastructure for different cloud providers?
Which task does terraform init not perform?
When do you need to explicitly execute Terraform in refresh-only mode?
You need to destroy all of the resources in your Terraform workspace, except for aws_instance.ubuntu[1], which you want to keep. How can you tell Terraform to stop managing that specific resource without destroying it?
When you run terraform apply, the Terraform CLI will print output values from both the root module and any child modules.
Which of the following command would be use to access all of the attributes and details of a resource managed by Terraform?
What information does the public Terraform Module Registry automatically expose about published modules?
Which configuration consistency errors does terraform validate report?
Which of the following is not a valid string function in Terraform?
Which argument can you use toprevent unexpected updatesto a module ' s configuration when calling Terraform Registry modules?
You want to bring an existing database under Terraform management. What information is required to create a new import block for the database?
Pick the two correct responses below.
When should you use the terraform force-unlock command?
All standard backend types support state locking, and remote operations like plan, apply, and destroy.
Which type of block fetches or computes information for use elsewhere in a Terraform configuration?
You have to initialize a Terraform backend before it can be configured.
A Terraform output that sets the " sensitive " argument to true will not store that value in the state file.
Which of the following is not a key principle of infrastructure as code?
Exhibit:
Root module configuration:
output " vnet_id " {
value = module.my_network.vnet_id
}
Error:
Error: Reference to undeclared output value
on main.tf line 12, in output " vnet_id " :
12: value = module.my_network.vnet_id
You are using a networking module in your Terraform configuration with the name my_network. Your root module includes the configuration shown. When you run terraform validate, you get the error shown. Which option would successfully retrieve this value from your networking module?
Your team adopts AWS CloudFormation as the standardized method for provisioning public cloud resources. Which scenario presents a challenge for your team?
What Terraform command always causes a state file to be updated with changes that might have been made outside of Terraform?
The_________determines how Terraform creates, updates, or delete resources.
Only the user that generated a plan may apply it.
When does Sentinel enforce policy logic during a Terraform Cloud run?
A senior admin accidentally deleted some of your cloud instances. What will Terraform do when you run terraform apply?
By default, if you do not define a backend for your configuration, where does Terraform store information about the resources that it manages?
Which of the following are advantages of using infrastructure as code (laC) instead of provisioning with a graphical user interface (GUI)? Choose two correct answers.
Terraformrequiresthe Go runtime as a prerequisite for installation.
You modified your Terraform configuration to fix a typo in the resource ID by renaming it from photoes to photos. What configuration will you add to update the resource ID in state without destroying the existing resource?
Original configuration:
resource " aws_s3_bucket " " photoes " {
bucket_prefix = " images "
}
Updated configuration:
resource " aws_s3_bucket " " photos " {
bucket_prefix = " images "
}
Which of the following methods, used to provision resources into a public cloud, demonstrates the concept of infrastructure as code?
A resource block is shown in the Exhibit space of this page. What is the Terraform resource name of the resource block?
You can reference a resource created with for_each using a Splat ( *) expression.
Why is it considered important to treat your Terraform state file as sensitive?
A Terraform backend determines how Terraform loads state and stores updates when you execute which command?
Which features do HCP Terraform workspaces provide that are not available in Terraform Community Edition? (Pick the 3 correct responses below.)
Which of these is true about Terraform ' s plugin-based architecture?
If a module declares a variable without a default value, you must pass the value of the variable within the module block when you call the module in your configuration.
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 provider for this resource?
A resource block is shown in the Exhibit section of this page. How would you reference the attribute name of this resource in HCL?
What does state looking accomplish?
Define the purpose of state in Terraform.
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?
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 init retrieves and caches the configuration for all remote modules.
INcheck block ' s assertion fails, Terraform blocks the current operation from executing.
Which of these workflows is only enabled by the use of Infrastructure as Code?
Running terraform fmt without any flags in a directory with Terraform configuration files check the formatting of those files without changing their contents.
What is the primary purpose of IaC (Infrastructure as Code)?
Which situation will return an error when you run terraform validate?
You decide to move a Terraform state file to Amazon S3 from another location. You write the code below into a file called backend.tf.
Which command will migrate your current state file to the new S3 remote backend?
All modules published on the official Terraform Module Registry have been verified by HasihCorp.
Which syntax check returns an error when you run terraform validate?
When does Terraform create the .terraform.lock.hc1 file?
What command can you run to generateDOT (Graphviz)formatted data to visualize Terraform dependencies?
What does the import block do?
You manage two workspaces in your HCP Terraform organization. The first workspace manages your network configuration. The second workspace manages your compute resources and retrieves values from the networking workspace.
What HCP Terraform feature lets you run an apply operation on the compute workspace every time you update the networking workspace?
What does terraform destroy do?
The Terraform binary version and provider versions must match each other in a single configuration.
terraform init creates an example main.tf file in the current directory.
Which is a benefit of the Terraform state file?
Which of the following should you add in the required_providers block to define a provider version constraint?
What is the provider for the resource shown in the Exhibit?
resource " aws_vpc " " main " {
name = " test "
}
Terraform configuration can only import modules from the public registry.
When do changes invoked by terraform apply take effect?
When should you use the force-unlock command?
Which method for sharing Terraform configurations fulfills the following criteria:
1. Keeps the configurations confidential within your organization
2. Support Terraform’s semantic version constrains
3. Provides a browsable directory
Which command must you run before you run a plan or apply for the first time?
You provisioned virtual machines (VMs) on Google Cloud Platform using the gcloud command-line tool.
What must be done to manage these VMs using Terraform instead? Pick the two correct responses.
Which of these are features of HCP Terraform/Terraform Cloud? (Pick the 2 correct responses)
What does Terraform use the .terraform.lock.hc1 file for?
Which of the following should you put into the required_providers block?
One remote backend configuration always maps to a single remote workspace.
You can define multiple backend blocks in your Terraform configuration to store your state in multiple locations.
Terraform can only manage resource dependencies if you set them explicitly with the depends_on argument.
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?
You have a list of numbers that represents the number of free CPU cores on each virtual cluster:
numcpus = [ 18, 3, 7, 11, 2 ]
What Terraform function could you use to select the largest number from the list?
Which Terraform collection type stores values as key/value pairs?
What is the purpose of the terraform.lock.hcl file in Terraform?
Terraform configuration can only call modules from the public registry.
The -refresh-only parameter will update your state file when used with terraform plan.
Any user can publish modules to the public Terraform Module Registry.
What is modified when executing Terraform inrefresh-only mode?
The exhibit shows part of a configuration that you have been asked to update.
The name of the Azure Virtual Network must be set to the name of the resource group, followed by a dash and the word vnet.
Exhibit
data " azurerm_resource_group " " example " {
name = var.resource_group_name
}
resource " azurerm_virtual_network " " example " {
name = ________________________
}
Which expression fulfills this requirement?
Which task does terraform init not perform?
Once you configure a new Terraform backend with a terraform code block, which command(s) should you use to migrate the state file?
You just upgraded the version of a provider in an existing Terraform project. What do you need to do to install the new provider?
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 kind of configuration block will manage an infrastructure object with settings specified within the block?

A resource block is shown in the Exhibit space of this page. What is the provider for this resource?
Which are advantages of IaC (Infrastructure as Code) patterns instead of manual infrastructure management?
Pick the 2 correct responses below.
A developer launched a VM outside of the Terraform workflow and ended up with two servers with the same name. They are unsure which VM is managed with Terraform, but they do have a list of all active VM IDs. Which method could you use to determine which instance Terraform manages?
Terraform variables and outputs that set the description argument will store that description in the state file.
Does terraform init create an example main.tf file in the current directory?
Which of the following does HCP Terraform perform during a health assessment for a workspace?
Which of the following is not true of Terraform providers?
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 3)
What is a key benefit of the Terraform state file?