HashiCorp Certified: Terraform Associate (004) (HCTA0-004)
Last Update May 31, 2026
Total Questions : 359
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.
Module version is required to reference a module on the Terraform Module Registry.
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.
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?
As a developer, you want to ensure your plugins are up to date with the latest versions. Which Terraform command should you use?
terraform validate confirms that your infrastructure matches the Terraform state file.
Exhibit:
resource " kubernetes_namespace " " example " {
name = " test "
}
A resource block is shown in the exhibit. How would you reference the name attribute of this resource in HCL?
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?
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?
When using multiple configuration of the same Terraform provider, what meta-argument must you include in any non-default provider configurations?
You are updating a child module with the resource block shown in the exhibit below. The public_ip attribute of the resource needs to be accessible to the parent module.
Exhibit:
resource " aws_instance " " example " {
ami = " ami-0a123456789abcdef "
instance_type = " t3.micro "
}
How do you meet this requirement?
A Terraform backend determines how Terraform loads state and stores updates when you execute which command?
You’ve updated your Terraform configuration, and you need to preview the proposed changes to your infrastructure. Which command should you run?
What is the Terraform style convention for indenting a nesting level compared to the one above it?
Which of the following isnotan advantage of using Infrastructure as Code (IaC) operations?
If you update the version constraint in your Terraform configuration, Terraform will update your lock file the next time you run terraform Init.
How does the use of Infrastructure as Code (IaC) enhance the reliability of your infrastructure?
Pick the two correct responses below.
How would you output returned values from a child module in the Terraform CLI output?
When a check block’s assertion fails, Terraform blocks the current operation from executing.
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?
You ate making changes to existing Terraform code to add some new infrastructure. When is the best time to run terraform validate?
Infrastructure as Code (laC) can be stored in a version control system along with application code.
A module block is shown in the Exhibit space of this page. When you use a module block to reference a module from the Terraform Registry such as the one in the example, how do you specify version 1.0.0 of the module?
Which of these actions will prevent two Terraform runs from changing the same state file at the same time?
You are using a networking module in your Terraform configuration with the name label my-network. In your main configuration you have the following code:
When you run terraform validate, you get the following error:
What must you do to successfully retrieve this value from your networking module?
Terraform can only manage resource dependencies if you set them explicitly with the depends_on argument.
You can configure multiple cloud blocks in your Terraform configuration to connect your workspace to both HCP Terraform and your Terraform Enterprise instance.
terraform apply is failing with the following error. What next step should you take to determine the root cause of the problem?
Error:
yaml
CopyEdit
Error loading state: AccessDenied: Access Denied
status code: 403, request id: 288766CE5CCA24A0, host id: web.example.com
Exhibit:
Error: Saved plan is stale
The given plan file can no longer be applied because the state was changed by another operation after the plan was created.
You have a saved execution plan containing desired changes for infrastructure managed by Terraform. After running terraform apply my.tfplan, you receive the error shown. How can you apply the desired changes? (Pick the 2 correct responses below.)
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?
What functionality do providers offer in Terraform?(Pick 3 correct responses)
Which option cannot be used to keep secrets out of Terraform configuration files?
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?
Which of the following is availableonlyinHCP Terraform workspacesandnot in Terraform CLI?
The Terraform binary version and provider versions must match each other in a single configuration.
Which of the following locations can Terraform use as aprivate sourcefor modules?(Pick 2 correct responses)
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)
When you use a backend that requires authentication, it is best practice to:
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)
What kind of configuration block will create an infrastructure object with settings specified within the block?
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?
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?
You ' re writing a Terraform configuration that needs to read input from a local file called id_rsa.pub . Which built-in Terraform function can you use to import the file ' s contents as a string?
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?
You’ve just finished refactoring part of your Terraform workspace’s configuration to use a module to manage some of your resources. When you plan your changes, you notice that Terraform will destroy and recreate the affected resources. Doing so could cause unintended downtime in the application your workspace manages. What supported approach should you take to complete the refactor without destroying and recreating your resources?
You have developed a new cloud-based service that uses proprietary APIs and want to use Terraform to create, manage, and delete users from the service. How can Terraform interact with the service?
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?
You have declared a variable called var.list which is a list of objects that all have an attribute id . Which options will produce a list of the IDs? Choose two correct answers.
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 actions are forbidden when the Terraform state file is locked? (Pick the 3 correct responses)
terraform apply will fail if you have not run terraform plan first to update the plan output.
Which of the following module source paths does not specify a remote module?
A resource block is shown in the Exhibit space of this page. What is the Terraform resource name of the resource block?
You can configure Terraform to log to a file using the TF_LOG environment variable.
When you use a backend that requires authentication, it is best practice to:
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?
Terraform requires using a different provider for each cloud provider where you want to deploy resources.
How do you specify a module’s version when publishing it to the public terraform Module Registry?
You want to define multiple data disks as nested blocks inside the resource block for a virtual machine. What Terraform feature would help you define the blocks using the values in a variable?
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?
One remote backend configuration always maps to a single remote workspace.
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.
Which command must you run before you run a plan or apply for the first time?
Which of these are features of HCP Terraform/Terraform Cloud? (Pick the 2 correct responses)
Which command must you first run before performing further Terraform operations in a working directory?
Which of the following does terraform apply change after you approve the execution plan? (Choose two.)
What is the provider for the resource shown in the Exhibit?
resource " aws_vpc " " main " {
name = " test "
}
One cloud block always maps to a single HCP Terraform/Terraform Cloud workspace.
Which are forbidden actions when the terraform state file is locked? Choose three correct answers.
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 2 correct responses below:
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 of the following commands would you use to access all of the attributes and details of a resource managed by Terraform?
Where does HashiCorp recommend you store API tokens and other secrets within your team ' s Terraform workspaces?
Pick three correct responses below:
The Terraform configuration shown in the Exhibit space on this page v/ill create a new AWS instance.
When you run terraform apply -refresh-only, which of the following is not consulted by Terraform to update the state file?
You need to deploy resources into two different regions in the same Terraform configuration using the block shown in the exhibit below.
What do you need to add to the provider configuration to deploy the resource to the us-west-2 AWS region?
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.
The_________determines how Terraform creates, updates, or delete resources.
Exhibit:
data " vsphere_datacenter " " dc " {}
resource " vsphere_folder " " parent " {
path = " Production "
type = " vm "
datacenter_id = _________
}
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?
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?
Exhibit:
variable " sizes " {
type = list(string)
description = " Valid server sizes "
default = [ " small " , " medium " , " large " ]
}
A variable declaration is shown in the exhibit. Which is the correct way to get the value of medium from this variable?
Terraform stores the value of an output in its state file, even if the sensitive argument is set to true.
What information does the public Terraform Module Registry automatically expose about published modules?
What is the Terraform style convention for indenting a nesting level compared to the one above it?