HashiCorp Certified: Terraform Associate (004) (HCTA0-004)
Last Update Oct 12, 2026
Total Questions : 385
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 developer on your team is going to leaf down an existing deployment managed by Terraform and deploy a new one. However, there is a server resource named aws instant.ubuntu[l] they would like to keep. What command should they use to tell Terraform to stop managing that specific resource?
You have a list of numbers representing the number of free CPU cores on each virtual cluster:
numcpus = [18, 3, 7, 11, 2]
Which Terraform built-in function would you use to select the largest number from the list?
What functionality do providers offer in Terraform?(Pick 3 correct responses)
By default, if you do not define a backend for your configuration, where does Terraform store information about the resources that it manages?
What is the provider for the resource shown in the Exhibit?
resource " aws_vpc " " main " {
name = " test "
}
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?
Which of the following ate advantages of using infrastructure as code (laC) instead of provisioning with a graphical user interface (GUI)? Choose two correct answers.
Which of the following is availableonlyinHCP Terraform workspacesandnot in Terraform CLI?
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?
You have a simple Terraform configuration containing one virtual machine (VM) in a cloud provider. You run terraform apply and the VM is created successfully.
What will happen if you delete the VM using the cloud provider console, then run terraform apply again without changing any Terraform code?
You must use different Terraform commands depending on the cloud provider you use.
How do you specify a module’s version when publishing it to the public terraform Module Registry?
What command can you run to generateDOT (Graphviz)formatted data to visualize Terraform dependencies?
Which command should you run to check if all code in a Terraform configuration that references multiple modules is properly formatted without making changes?
Which provider authentication method prevents credentials from being stored in the state file?
A provider configuration block is required in every Terraform configuration.
Example:
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?
Your security team scanned some Terraform workspaces and found secrets stored in plaintext in state files. How can you protect that data?
Which option cannot be used to keep secrets out of Terraform configuration files?
As a developer, you want to ensure your plugins are up to date with the latest versions. Which Terraform command should you use?
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?
Which of the following commands would you use to access all of the attributes and details of a resource managed by Terraform?
Why is it considered important to treat your Terraform state file as sensitive?
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?
The -refresh-only parameter will update your state file when used with terraform plan.
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?
Which of the following arguments are required when declaring a Terraform output?
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)
Which is the best way to specify a tag of v1.0.0 when referencing a module stored in Git (for example.
Git::https://example.com/vpc.git)?
You much initialize your working directory before running terraform validate.
Which of the following should you add in the required_providers block to define a provider version constraint?
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?
All standard backend types support state locking, and remote operations like plan, apply, and destroy.
terraform destroy is the only way to remove infrastructure with Terraform.
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?
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?
What does this code do?
terraform { required_providers { aws = " > = 3.0 " }}
Your team is collaborating on infrastructure using Terraform and wants to format code to follow Terraform language style conventions. How can you update your code to meet these requirements?
Which of the following methods, used to provision resources into a public cloud, demonstrates the concept of infrastructure as code?
You need to determine from which paths Terraform is loading the providers referenced in your *.tf files.
How can you enable additional logging to see this information?
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.
The_________determines how Terraform creates, updates, or delete resources.
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?
What Terraform command always causes a state file to be updated with changes that might have been made outside of Terraform?
Setting the TF_LOG environment variable to DEBUG causes debug messages to be logged into stdout.
Which command must you run before you run a plan or apply for the first time?
Which option does not keep secret variable values out of Terraform configuration files?
When you initialize Terraform, where does it cache modules from the public Terraform Registry?
Which of the following can you do with terraform plan?
Pick the two correct responses below.
Which of these are features of HCP Terraform/Terraform Cloud? Pick the 2 correct responses below.
You have just upgraded the version constraint of a provider in an existing Terraform configuration. What command will install the new provider version?
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?
Terraform can only manage resource dependencies if you set them explicitly with the depends_on argument.
Where does HashiCorp recommend you store API tokens and other secrets within your team ' s Terraform workspaces?
Pick three correct responses below:
Which of these are features of Terraform Cloud? Choose two correct answers.
terraform validate confirms that your infrastructure matches the Terraform state file.
You ate making changes to existing Terraform code to add some new infrastructure. When is the best time to run terraform validate?
You previously applied your Terraform configuration to create infrastructure in your cloud provider. Your configuration uses the local backend, and you accidentally deleted your terraform.tfstate file.
What does Terraform do the next time you run terraform apply?
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?
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?
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?
When you run terraform apply, the Terraform CLI will print output values from both the root module and any child modules.
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.
Which argument can you use toprevent unexpected updatesto a module ' s configuration when calling Terraform Registry modules?
What value does the Terraform Cloud private registry provide over the public Terraform Module Registry?
Does terraform init create an example main.tf file in the current directory?
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?
What kind of configuration block will manage an infrastructure object with settings specified within the block?
What does Terraform use to deploy infrastructure for different cloud providers?
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
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?
terraform validate reports syntax check errors for which of the following?
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)
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?
Which type of information does the Terraform Registry provide about the modules it hosts?
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.
Exhibit:
provider " aws " { region = " us-east-1 " }
provider " aws " { region = " us-west-2 " }
You need to deploy resources into two different AWS regions in the same Terraform configuration using the provider blocks shown in the exhibit. What do you need to add to the provider configuration to deploy a resource to the us-west-2 AWS region?
Running terraform fmt without any flags in a directory with Terraform configuration files check the formatting of those files without changing their contents.
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.
You want to create a string that is a combination of a generated random_id and a variable, and reuse that string several times in your configuration.
What is the simplest correct way to implement this without repeating the random_id and variable?
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?
How can a ticket-based system slow down infrastructure provisioning and limit the ability to scale? Choose two correct answers.
Which are benefits of migrating from a local state backend to a remote backend? (Pick the 2 correct responses below.)