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.
When using multiple configurations of the same Terraform provider, what meta-argument must you include in any non-default provider configurations?
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?
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?
What does this code do?
terraform { required_providers { aws = " > = 3.0 " }}
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?
A module can always refer to all variables declared in its parent module.
You can define multiple backend blocks in your Terraform configuration to store your state in multiple locations.
Your team often uses API calls to create and manage cloud infrastructure. In what ways does Terraform differ from conventional infrastructure management approaches?
How do you specify a module’s version when publishing it to the public terraform Module Registry?
What is a key benefit of the Terraform state file?
What is modified when executing Terraform inrefresh-only mode?
terraform apply will fail if you have not run terraform plan first to update the plan output.
You can configure multiple cloud blocks in your Terraform configuration to connect your workspace to both HCP Terraform and your Terraform Enterprise instance.
When you run terraform apply, the Terraform CLI will print output values from both the root module and any child modules.
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.
What value does the Terraform Cloud private registry provide over the public Terraform Module Registry?
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
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 information does the public Terraform Module Registry automatically expose about published modules?
Which of these actions will prevent two Terraform runs from changing the same state file at the same time?
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?
The HCP Terraform private registry keeps the module configurations confidential within your organization.
Which are examples of infrastructure as code? Choose two correct answers.
Where can Terraform not load a provider from?
When should you run terraform init?
What Terraform command always causes a state file to be updated with changes that might have been made outside of Terraform?
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?
Which two steps are required to provision new infrastructure in the Terraform workflow? Choose two correct answers.
Which of the following locations can Terraform use as aprivate sourcefor modules?(Pick 2 correct responses)
A Terraform local value can reference other Terraform local values.
Which statements are true? Choose two correct answers.
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?
Which Terraform collection type should you use to store key/value pairs?
How does the Terraform cloud integration differ from other state backends such as S3, Consul,etc?
By default, if you do not define a backend for your configuration, where does Terraform store information about the resources that it manages?
A data source is shown in the exhibit below.
How do you reference the id attribute of this data source?

}
}
The terraform output command shows outputs from child modules.
When using multiple configuration of the same Terraform provider, what meta-argument must you include in any non-default provider configurations?
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)
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?
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?
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?
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.
Which command should you run to check if all code in a Terraform configuration that references multiple modules is properly formatted without making changes?
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?
If you update the version constraint in your Terraform configuration, Terraform will update your lock file the next time you run terraform Init.
What type of block is used to construct a collection of nested configuration blocks?
What is terraform plan -refresh-only intended to detect?
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:
Which of the following should you put into the required_providers block?
Terraform variable names are saved in the state file.
Which parameters does terraform import require? Choose two correct answers.
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?
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)?
The Terraform binary version and provider versions must match each other in a single configuration.
Which features do HCP Terraform workspaces provide that are not available in Terraform Community Edition? (Pick the 3 correct responses below.)
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 task does terraform init not perform?
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?
Module variable assignments are inherited from the parent module and you do not need to explicitly set them.
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?
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?
Which command lets you experiment with terraform expressions?
When should you use the terraform force-unlock command?
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?
Which of these workflows is only enabled by the use of Infrastructure as Code?
Infrastructure as Code (laC) can be stored in a version control system along with application code.
Which command(s) adds existing resources in a public cloud into Terraform state?
What is the primary purpose of IaC (Infrastructure as Code)?
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?
It is best practice to store secret data in the same version control repository as your Terraform configuration.
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?
Why would you use the -replace flag for terraform apply?
Before you can use a new backend or HCP Terraform/Terraform Cloud integration, you must first execute terraform init.
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?
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?
INcheck block ' s assertion fails, Terraform blocks the current operation from executing.
When you use a backend that requires authentication, it is best practice to:
Which argument can you set on a module block to prevent Terraform from updating the module’s configuration during an init or get operation?
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 is the provider for the resource shown in the Exhibit?
resource " aws_vpc " " main " {
name = " test "
}
Your team adopts AWS CloudFormation as the standardized method for provisioning public cloud resources. Which scenario presents a challenge for your team?
You have deployed a new webapp with a public IP address on a cloud provider. However, you did not create any outputs for your code. What is the best method to quickly find the IP address of the resource you deployed?
What feature stops multiple users from operating on the Terraform state at the same time?
Which is a recommended way to share Terraform state across teams?
You have a saved execution plan containing desired changes for infrastructure managed by Terraform. After running the command terraform apply my.tfplan, you receive the error shown in the exhibit below.
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.
How can you apply the desired changes? (Choose TWO correct answers)
Which of the following is not a key principle of infrastructure as code?
You much initialize your working directory before running terraform validate.
What does Terraform not reference when running a terraform apply -refresh-only ?
Terraform encrypts sensitive values stored in your state file.
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?
Using the terraform state rm command against a resource will destroy it.
Which command add existing resources into Terraform state?
You want to create a string that combines 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?
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?
Setting the TF_LOG environment variable to DEBUG causes debug messages to be logged into stdout.
Which are forbidden actions when the terraform state file is locked? Choose three correct answers.
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.
Which situation will return an error when you run terraform validate?
Why is it considered important to treat your Terraform state file as sensitive?
Module version is required to reference a module on the Terraform Module Registry.
Terraform installs its providers during which phase?
3 Months Free Update
3 Months Free Update
3 Months Free Update