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.
Which of the following command would be use to access all of the attributes and details of a resource managed by Terraform?
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?
In Terraform HCL, an object type of object({name=string, age-number}) would match this value.

When a check block’s assertion fails, Terraform blocks the current operation from executing.
You can configure Terraform to log to a file using the TF_LOG environment variable.
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?
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?
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?
What feature stops multiple users from operating on the Terraform state at the same time?
Which of these are features of HCP Terraform/Terraform Cloud? Pick the 2 correct responses below.
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?
As a member of an operations team that uses infrastructure as code (lac) practices, you are tasked with making a change to an infrastructure stack running in a public cloud. Which pattern would follow laC best practices for making a change?
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?
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?
Setting the TF_LOG environment variable to DEBUG causes debug messages to be logged into stdout.
Terraform configuration (including any module references) can contain only one Terraform provider type.
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?
In a Terraform Cloud workpace linked to a version control repository speculative plan rum start automatically commit changes to version control.
When using a remote backend or terraform Cloud integration, where does Terraform save resource sate?
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?
What are some benefits of using Sentinel with Terraform Cloud/Terraform Cloud? Choose three correct answers.
Where does HashiCorp recommend you store API tokens and other secrets within your team ' s Terraform workspaces?
Pick three correct responses below:
Which provider authentication method prevents credentials from being stored in the state file?
Which argument can you set on a module block to prevent Terraform from updating the module’s configuration during an init or get operation?
Which option cannot be used to keep secrets out of Terraform configuration files?
When using multiple configurations of the same Terraform provider, what meta-argument must you include in any non-default provider configurations?
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 of the following does HCP Terraform perform during a health assessment for a workspace?
Pick the 2 correct responses below:
Your team adopts AWS CloudFormation as the standardized method for provisioning public cloud resources.
Which scenario presents a challenge for your team?
Which features do HCP Terraform workspaces provide that are not available in Terraform Community Edition? (Pick the 3 correct responses below.)
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?
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.)
Which parameters does the import block require? (Pick the 2 correct responses below.)
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)
Which of these ate secure options for storing secrets for connecting to a Terraform remote backend? Choose two correct answers.
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?
Which of these actions are forbidden when the Terraform state file is locked? (Pick the 3 correct responses)
When using Terraform to deploy resources into Azure, which scenarios are true regarding state files? (Choose two.)
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 "
}
Terraform stores the value of an output in its state file, even if the sensitive argument is set to true.
The exhibit below shows part of a Terraform configuration you have been asked to update. The name of the Azure Virtual Network should 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?
Terraform can only manage resource dependencies if you set them explicitly with the depends_on argument.
What functionality do providers offer in Terraform? (Pick the 3 correct responses below.)
By default, if you do not define a backend for your configuration, where does Terraform store information about the resources that it manages?
When should you write Terraform configuration files for existing infrastructure that you want to start managing with Terraform?
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?
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 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?
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 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 must use different Terraform commands depending on the cloud provider you use.
When you run terraform apply, the Terraform CLI will print output values from both the root module and any child modules.
How would you output returned values from a child module in the Terraform CLI output?
Running terraform fmt without any flags in a directory with Terraform configuration files will check the formatting of those files, but will never change their contents.
Which of the following should you add in the required_providers block to define a provider version constraint?
Which of the following does HCP Terraform perform during a health assessment for a workspace?
Where in your Terraform configuration do you specify remote state storage settings?
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 have set the TF_LOG_PATH environment variable for Terraform, and you would like to ensure the logs contain all debug-level messages and verbose process logs.
Which action should you take?
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 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 can you do with terraform plan?
Pick the two correct responses below.
Which of the following arguments are required when declaring a Terraform output?
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 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?
Your Terraform configuration manages a resource that requires maximum uptime. You need to update the resource, and when you run terraform plan, Terraform indicates that the update requires the resource to be destroyed and recreated.
Which lifecycle rule can you add to the resource to reduce downtime while still applying the update?
Your team adopts AWS CloudFormation as the standardized method for provisioning public cloud resources. Which scenario presents a challenge for your team?
You modified your Terraform configuration and run Terraform plan to review the changes. Simultaneously, your teammate manually modified the infrastructure component you are working on. Since you already ran terraform plan locally, the execution plan for terraform apply will be the same.
Which command(s) adds existing resources in a public cloud into Terraform state?
If you update the version constraint in your Terraform configuration, Terraform will update your lock file the next time you run terraform Init.
Which of the following should you add in the required_providers block to define a provider version constraint?
One cloud block always maps to a single HCP Terraform/Terraform Cloud workspace.
How does the Terraform cloud integration differ from other state backends such as S3, Consul,etc?




