Free Practice Questions for the HashiCorp Terraform Associate Terraform-Associate-004 Exam (2026 Updated)
At Marks4sure, we are dedicated to providing IT professionals with the most accurate and reliable preparation materials for the HashiCorp Terraform-Associate-004 exam. To support your certification journey, we have made a selection of our premium 2026 Terraform Associate practice questions and answers available completely free. You can take this practice test as many times as you need. Every question includes a detailed, expertly verified explanation to ensure you fully grasp the core security concepts before test day.
Your team adopts AWS CloudFormation as the standardized method for provisioning public cloud resources.
Which scenario presents a challenge for your team?
Running terraform fmt without any flags in a directory with Terraform configuration files check the formatting of those files without changing their contents.
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?
You can configure Terraform to log to a file using the TF_LOG environment variable.
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 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 "
}
If you update the version constraint in your Terraform configuration, Terraform will update your lock file the next time you run terraform Init.
How can you trigger a run in a Terraform Cloud workspace that is connected to a Version Control System (VCS) repository?
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?
Where does HashiCorp recommend you store API tokens and other secrets within your team’s Terraform workspaces?
Pick the three correct responses below.
Terraform variables and outputs that set the description argument will store that description in the state file.
How does an HCP Terraform integration using the cloud block differ from remote backends such as S3?
Why is it considered an anti-pattern to store your Terraform state in version control?
Which are advantages of IaC (Infrastructure as Code) patterns instead of manual infrastructure management?
Pick the 2 correct responses below.
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.
You have just developed a new Terraform configuration for two virtual machines with a cloud provider. You would like to create the infrastructure for the first time.
Which Terraform command should you runfirst?
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?
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?
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?
You are working on some new application features and you want to spin up a copy of your production deployment to perform some quick tests. In order to avoid having to configure a new state backend, what open source Terraform feature would allow you create multiple states but still be associated with your current code?
How would you reference the volume IDs associated with the ebs_block_device blocks in this configuration?

A module block used in your configuration is shown in the exhibit. You have been asked to update the version of this module from 4.2.1 to 5.0.0.
Exhibit:
module " compute " {
source = " Azure/compute/azurerm "
version = " 4.2.1 "
}
Which two steps must you take to accomplish this?
Which of these actions will prevent two Terraform runs from changing the same state file at the same time?
How does the use of Infrastructure as Code (IaC) enhance the reliability of your infrastructure?
Pick the two correct responses below.
You just scaled your VM infrastructure and realize you set the count variable to the wrong value. You correct the value and save your change. What must you do next to make your infrastructure match your configuration?

The Terraform configuration shown in the Exhibit space on this page v/ill create a new AWS instance.
A senior admin accidentally deleted some of your cloud instances. What will Terraform do when you run terraform apply?
Which of these statements about HCP Terraform/Terraform Cloud workspaces is false?
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 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?
If you don’t use the local Terraform backend, where else can Terraform save resource state?
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?
Which of the following does terraform apply change after you approve the execution plan? (Choose two.)
Which of these are features of HCP Terraform/Terraform Cloud? (Pick the 2 correct responses)
Why is it considered important to treat your Terraform state file as sensitive?
When using multiple configurations of the same Terraform provider, what meta-argument must you include in any non-default provider configurations?
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?
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 parameters does the import block require? (Pick the 2 correct responses below.)
How do you specify a module’s version when publishing it to the public terraform Module Registry?
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?
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 should you add in the required_providers block to define a provider version constraint?
When using a remote backend or terraform Cloud integration, where does Terraform save resource sate?
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?
You are responsible for a set of infrastructure that is managed by two workspaces: example-network and example-compute. The example-compute workspace uses data from output values configured in the example-network workspace and must be deployed afterward. Currently, this is a manual process:
An operator deploys changes to the example-network workspace.
They manually copy the output values from the example-network workspace to input variables configured for the example-compute workspace.
They deploy the example-compute workspace.
Which HCP Terraform features can you use to automate this process?
Pick the two correct responses below.
What are some benefits of using Sentinel with Terraform Cloud/Terraform Cloud? Choose three correct answers.
Which type of information does the Terraform Registry provide about the modules it hosts?
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?
Which HCP Terraform feature is recommended when you want to use the same cloud provider credentials across multiple workspaces?
You should run terraform fnt to rewrite all Terraform configurations within the current working directory to conform to Terraform-style conventions.
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?
Which argument can you set on a module block to prevent Terraform from updating the module’s configuration during an init or get operation?
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?
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?
Your root module contains a variable namednum_servers. Which is the correct way to pass its value to a child module with an input namedservers?
When a check block’s assertion fails, Terraform blocks the current operation from executing.
Which of the following can you do with terraform plan?
Pick the two correct responses below.
Which two steps are required to provision new infrastructure in the Terraform workflow? Choose two correct answers.
When you run terraform apply, the Terraform CLI will print output values from both the root module and any child modules.
Which two steps are required to provision new infrastructure in the Terraform workflow? (Pick the 2 correct responses below.)
What type of information can be found on the Terraform Registry when using published modules?
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 terraform apply again immediately afterward without changing any Terraform code?
Your team is using version 3.1.4 of a module from the public Terraform Registry, and they are worried about possible breaking changes in future versions of the module. Which version argument should you add to the module block to prevent newer versions from being used?
Which of these are features of HCP Terraform/Terraform Cloud? Pick the 2 correct responses below.
Your risk management organization requires that new AWS S3 buckets must be private and encrypted at rest. How can Terraform Cloud automatically and proactively enforce this security control?
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?
What does Terraform use to deploy infrastructure for different cloud providers?
You have two separate Terraform configurations:
Configuration A provisions a virtual network and subnets.
Configuration B provisions compute resources that must be attached to those subnets.
In Configuration B, you have a terraform_remote_state data source configured to read Configuration A’s local state file. When running terraform plan for Configuration B in a CI/CD pipeline, Terraform fails because the state file cannot be found and is not accessible to the pipeline runtime.
What is the best solution to reliably access the state data from Configuration A in this scenario?
Which option does not keep secret variable values out of Terraform configuration files?
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)
