HashiCorp Certified: Terraform Associate (004) (HCTA0-004)
Last Update Jul 26, 2026
Total Questions : 366
We are offering FREE Terraform-Associate-004 HashiCorp exam questions. All you do is to just go and sign up. Give your details, prepare Terraform-Associate-004 free exam questions and then go for complete pool of HashiCorp Certified: Terraform Associate (004) (HCTA0-004) test questions that will help you more.
A Terraform output that sets the " sensitive " argument to true will not store that value in the state file.
You can define multiple backend blocks in your Terraform configuration to store your state in multiple locations.
Which of these are features of HCP Terraform/Terraform Cloud? Pick the 2 correct responses below.
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?
Which type of block fetches or computes information for use elsewhere in a Terraform configuration?
Exhibit:
module " web_stack " {
source = " ./modules/web_stack "
}
Your configuration defines the module block shown in the exhibit. The web_stack module accepts an input variable named servers. Which of the following changes to the module block sets the servers variable to the value of 3?
While attempting to deploy resources into your cloud provider using Terraform, you begin to see some odd behavior and experience slow responses. In order to troubleshoot you decide to turn on Terraform debugging. Which environment variables must be configured to make Terraform ' s logging more verbose?
How do you specify a module’s version when publishing it to the public terraform Module Registry?
You created infrastructure outside the Terraform workflow that you now want to manage using Terraform. Which command brings the infrastructure into Terraform state?
Your team adopts AWS CloudFormation as the standardized method for provisioning public cloud resources.
Which scenario presents a challenge for your team?
You have provisioned some virtual machines (VMs) on Google Cloud Platform (GCP) using the gcloud command line tool. However, you are standardizing with Terraform and want to manage these VMs using Terraform instead. What are the two things you must do to achieve this? Choose two correct answers.
A resource block is shown in the Exhibit section of this page. How would you reference the attribute name of this resource in HCL?
Which command generates DOT (Document Template) formatted data to visualize Terraform dependencies?
Which parameters does the import block require? (Pick the 2 correct responses below.)
Which two steps are required to provision new infrastructure in the Terraform workflow? Choose two correct answers.
You are writing a child Terraform module that provisions an AWS instance. You want to reference the IP address returned by the child module in the root configuration. You name the instance resource " main ' .
Which of these is the correct way to define the output value?
Exhibit:
module " network " {
source = " terraform-google-modules/network/google "
version = " ~ > 11.0 "
}
What version of the source module does Terraform allow with the module block shown in the exhibit?
Exhibit:
resource " azurerm_linux_web_app " " app " {
name = " example-app "
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
service_plan_id = azurerm_service_plan.plan.id
identity {
type = " UserAssigned "
identity_ids = [azurerm_user_assigned_identity.app.id]
}
}
resource " azurerm_role_assignment " " kv_access " {
scope = azurerm_key_vault.kv.id
role_definition_name = " Key Vault Secrets User "
principal_id = azurerm_user_assigned_identity.app.principal_id
}
Two resource blocks are shown: azurerm_linux_web_app and azurerm_role_assignment. When provisioned, the web app will use the role assignment during creation, so the role assignment must be created first. How do you ensure the azurerm_role_assignment resource is created first?
If a DevOps team adopts AWS CloudFormation as their standardized method for provisioning public cloud resoruces, which of the following scenarios poses a challenge for this team?
What does this code do?
terraform { required_providers { aws = " > = 3.0 " }}
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.
When you use a backend that requires authentication, it is best practice to:
You have multiple team members collaborating on infrastructure as code (IaC) using Terraform, and want to apply formatting standards for readability.
How can you format Terraform HCL (HashiCorp Configuration Language) code according to standard Terraform style convention?
What kind of configuration block will create an infrastructure object with settings specified within the block?
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?
Your team often uses API calls to create and manage cloud infrastructure. In what ways does Terraform differ from conventional infrastructure management approaches?
Which of the following arguments are required when declaring a Terraform output?
The_________determines how Terraform creates, updates, or delete resources.
Which of the following module source paths does not specify a remote module?
Which parameters does terraform import require? Choose two correct answers.
Part of a configuration is shown in the exhibit below.
You want to pass the id of the vsphere_datacenter data source to the datacenter_id argument of the vsphere_folder resource.
Which reference would you use?
Which two steps are required to provision new infrastructure in the Terraform workflow? (Pick the 2 correct responses below.)
You have used Terraform lo create an ephemeral development environment in the (loud 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 of the resources that mil be deleted? Choose two correct answers.
Your team uses HCP Terraform to manage infrastructure. You need to make a change to an infrastructure stack running in a public cloud. Which pattern follows Infrastructure as Code best practices for making the change?
One remote backend configuration always maps to a single remote workspace.
A provider configuration block is required in every Terraform configuration.
Example:

You have a simple Terraform configuration containing one VM (virtual machine) in a cloud provider. You run terraform apply and the VM is created successfully. What will happen if you run terraform apply again immediately afterwards without changing any Terraform code?
What functionality do providers offer in Terraform? (Pick the 3 correct responses below.)
What is the provider for the resource shown in the Exhibit?
resource " aws_vpc " " main " {
name = " test "
}
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.
terraform validate confirms that your infrastructure matches the Terraform state file.
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?
Why is it considered important to treat your Terraform state file as sensitive?
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?
A resource block is shown in the Exhibit space of this page. What is the Terraform resource name of that resource block?
You can execute terraform fmt to standardize all Terraform configurations within the current working directory to Terraform’s canonical format and style.
A data source is shown in the exhibit below.
How do you reference the id attribute of this data source?

}
}
What functionality do providers offer in Terraform?(Pick 3 correct responses)
Which of the following should you add in the required_providers block to define a provider version constraint?
In a HCP Terraform/Terraform Cloud workspace linked to a version control repository, speculative plan runs start automatically when you merge or commit changes to version control.
You ' re building a CI/CD (continuous integration/continuous delivery) pipeline and need to inject sensitive variables into your Terraform run. How can you do this safely?
terraform validate uses provider APIs to verify your infrastructure settings.
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?
You corrected a typo in a resource name, changing it from aws_s3_bucket.photoes to aws_s3_bucket.photos. You want to update the Terraform state so that the existing resource is recognized under the new name, without destroying and recreating it. Which configuration should you use?
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?
You use a cloud provider account that is shared with other team members. You previously used Terraform to create a load balancer that listens on port 80. After application changes, you updated the Terraform code to change the port to 443.
You run terraform plan and see that the execution plan shows the port changing from 80 to 443 like you intended and step away to grab some coffee.
In the meantime, another team member manually changes the load balancer port to 443 through the cloud provider console before you get back to your desk.
What will happen when you run terraform apply upon returning to your desk?
Your security team scanned some Terraform workspaces and found secrets stored in plaintext in state files. How can you protect that data?
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?
You are creating a reusable Terraform configuration and want to include an optional billing_dept tag so your Finance team can track team-specific spending on resources. Which of the following billing_dept variable declarations will achieve this?
Which of these statements about HCP Terraform/Terraform Cloud workspaces is false?
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 correct responses)
You can reference a resource created with for_each using a Splat ( *) expression.
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.
Exhibit:
data " aws_ami " " web " {
most_recent = true
owners = [ " self " ]
tags = {
Name = " web-server "
}
}
A data source is shown in the exhibit. How do you reference the id attribute of this data source?
In Terraform HCL, an object type of object({name=string, age-number}) would match this value.

You just upgraded the version of a provider in an existing Terraform project. What do you need to do to install the new provider?
When using multiple configuration of the same Terraform provider, what meta-argument must you include in any non-default provider configurations?
Your Terraform configuration declares a variable. You want to enforce that its value meets your specific requirements, and you want to block the Terraform operation if it does not. What should you add to your configuration?
You much initialize your working directory before running terraform validate.
You have created a main.tf Terraform configuration consisting of an application server, a database and a load balanced. You ran terraform apply and Terraform created all of the resources successfully.
Now you realize that you do not actually need the load balancer, so you run terraform destroy without any flags. What will happen?
After creating a new Terraform configuration, your configuration passes terraform validate but returns an “Access Denied” error from the cloud provider when running terraform plan.
Why did terraform validate not catch this issue?

A resource block is shown in the Exhibit space of this page. What is the provider for this resource?
You want to define a single input variable to capture configuration values for a server. The values must represent memory as a number, and the server name as a string.
Which variable type could you use for this input?
Which of the following locations can Terraform use as aprivate sourcefor modules?(Pick 2 correct responses)
Which of the following does terraform apply change after you approve the execution plan? (Choose two.)
Terraform stores the value of an output in its state file, even if the sensitive argument is set to true.