We at Crack4sure are committed to giving students who are preparing for the HashiCorp Terraform-Associate-004 Exam the most current and reliable questions . To help people study, we've made some of our HashiCorp Certified: Terraform Associate (004) (HCTA0-004) exam materials available for free to everyone. You can take the Free Terraform-Associate-004 Practice Test as many times as you want. The answers to the practice questions are given, and each answer is explained.
It is best practice to store secret data in the same version control repository as your Terraform configuration.
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 ' 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?
What kind of configuration block will manage an infrastructure object with settings specified within the block?
Which of the following commands would you use to access all of the attributes and details of a resource managed by Terraform?
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 of these statements about HCP Terraform/Terraform Cloud workspaces is false?
Select the command that doesn’t cause Terraform to refresh its state.
Which situation will return an error when you run terraform validate?
Which statements are true about terraform apply? (Choose TWO correct answers)
What does the import block do?
terraform init creates an example main.tf file in the current directory.
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 want to know from which paths Terraform is loading providers referenced in your Terraform configuration (* files). You need to enable additional logging messages to find this out. Which of the following would achieve this?
How can a ticket-based system slow down infrastructure provisioning and limit the ability to scale? Choose two correct answers.
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?
All standard backend types support state locking, and remote operations like plan, apply, and destroy.
Where in your Terraform configuration do you specify remote state storage settings?
Which type of information does the Terraform Registry provide about the modules it hosts?
What is modified when executing Terraform inrefresh-only mode?
Which of these are features of HCP Terraform/Terraform Cloud? (Pick the 2 correct responses)
A resource block is shown in the Exhibit space of this page. What is the Terraform resource name of that resource block?
In Terraform HCL, an object type of object({name=string, age-number}) would match this value.

When should you use the force-unlock command?
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?
When a check block’s assertion fails, Terraform blocks the current operation from executing.
Which task does terraform init not perform?
When using a remote backend or terraform Cloud integration, where does Terraform save resource sate?
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 these ate features of Terraform Cloud? Choose two correct answers.
Which of the following is not a valid string function in Terraform?
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?
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 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 configuration (including any module references) can contain only one Terraform provider type.
Terraform variable names are saved in the state file.
Where in your Terraform configuration do you specify a state backend?
Which type of block fetches or computes information for use elsewhere in a Terraform 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?
terraform apply will fail if you have not run terraform plan first to update the plan output.
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 two correct responses below.
Why would you use the -replace flag for terraform apply?
Your team adopts AWS CloudFormation as the standardized method for provisioning public cloud resources. Which scenario presents a challenge for your team?
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 these statements about Terraform Cloud workspaces is false?
The terraform output command shows outputs from child modules.
Which of these commands makes your code more human readable?
Which option does not keep secret variable values out of Terraform configuration files?
Why is it considered an anti-pattern to store your Terraform state in version control?
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.
Variables declared within a module are accessible outside of the module.
Which command(s) adds existing resources in a public cloud into Terraform state?
You are tasked with making a change to an infrastructure stack running in a public cloud using HCP Terraform/Terraform Cloud. Which pattern follows IaC best practices?
A data source is shown in the exhibit below.
How do you reference the id attribute of this data source?
}
}
Terraform requires using a different provider for each cloud provider where you want to deploy resources.
HashiCorp Configuration Language (HCL) supports user-denned functions.
Terraform variables and outputs that set the description argument will store that description in the state file.
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 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.
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?
Which command add existing resources into Terraform state?
What is the purpose of the terraform.lock.hcl file in Terraform?
You just upgraded the version of a provider in an existing Terraform project. What do you need to do to install the new provider?
What information does the public Terraform Module Registry automatically expose about published modules?
Why would you use the -replace flag for terraform apply?
What does the default " local " Terraform backend store?
You can reference a resource created with for_each using a Splat ( *) expression.
When using multiple configuration of the same Terraform provider, what meta-argument must you include in any non-default provider configurations?
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?
Which of these is stored in the .terraform directory?
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 is availableonlyinHCP Terraform workspacesandnot in Terraform CLI?
terraform destroy is the only way to remove infrastructure.
Which two steps are required to provision new infrastructure in the Terraform workflow? (Pick the 2 correct responses below.)
What is a key benefit of the Terraform state file?
Which of these are benefits of using Sentinel with HCP Terraform/Terraform Cloud? (Pick the 3 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 3 correct responses)
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?
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?
terraform init retrieves and caches the configuration for all remote modules.
Why is it important to treat your Terraform state file as sensitive?
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?
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 of these statements about HCP Terraform workspaces is false?
Using the terraform state rm command against a resource will destroy it.
Parent modules can always access a child module’s variable values.
In a Terraform Cloud workspace linked to a version control repository, speculative plan runs start automatically when you merge or commit changes to version control.
Which are examples of infrastructure as code? Choose two correct answers.
Which of the following is not a key principle of infrastructure as code?
Your security team scanned some Terraform workspaces and found secrets stored in plaintext in state files. How can you protect that data?
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?
Why is it considered important to treat your Terraform state file as sensitive?
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?
The public Terraform Module Registry is free to use.
Before you can use a remote backend, you must first execute terra-form init.
Changing the Terraform backend from the default " local " backend to a different one after performing your first terrafom apply is:
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?
Which of these are features of Terraform Cloud? Choose two correct answers.
What kind of configuration block will create an infrastructure object with settings specified within the block?
Which of the following should you put into the required_providers block?
Which of the following command would be use to access all of the attributes and details of a resource managed by Terraform?
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?
What does Terraform use to deploy infrastructure for different cloud providers?
Which of the following locations can Terraform use as aprivate sourcefor modules?(Pick 2 correct responses)
You’ve enabled DEBUG-level logging for Terraform, and you’d like to send the log data to a file. Which action should you take?
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?
What feature stops multiple users from operating on the Terraform state at the same time?
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?
Which of the following is not a valid Terraform variable type?
When you use a backend that requires authentication, it is best practice to:
3 Months Free Update
3 Months Free Update
3 Months Free Update