HashiCorp Terraform-Associate-004 HashiCorp Certified: Terraform Associate (004) (HCTA0-004) Exam Practice Test
Total 359 questions
HashiCorp Certified: Terraform Associate (004) (HCTA0-004) Questions and Answers
Which command must you first run before performing further Terraform operations in a working directory?
Which of the following are advantages of using infrastructure as code (laC) instead of provisioning with a graphical user interface (GUI)? Choose two correct answers.
Which configuration consistency errors does terraform validate report?
terraform validate uses provider APIs to verify your infrastructure settings.
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?
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?
What does Terraform not reference when running a terraform apply -refresh-only ?
What is an advantage of immutable infrastructure?
You ate making changes to existing Terraform code to add some new infrastructure. When is the best time to run terraform validate?
Exhibit:
module " web_stack " {
source = " ./modules/web_stack "
}
Your configuration defines the module block shown in the exhibit. The web_stack module accepts an input variable named servers. Which of the following changes to the module block sets the servers variable to the value of 3?
Which are benefits of migrating from a local state backend to a remote backend? (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)
You much initialize your working directory before running terraform validate.
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?
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)
What does the default " local " Terraform backend store?
Which provider authentication method prevents credentials from being stored in the state file?
What does terraform import do?
terraform init creates an example main.tf file in the current directory.
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?
All modules published on the official Terraform Module Registry have been verified by HasihCorp.
When using multiple configuration of the same Terraform provider, what meta-argument must you include in any non-default provider configurations?
When you run terraform apply, the Terraform CLI will print output values from both the root module and any child modules.
Terraform providers are always installed from the Internet.
What is the primary purpose of Infrastructure as Code (IaC)?
Your security team scanned some Terraform workspaces and found secrets stored in plaintext in state files. How can you protect that data?
When should you write Terraform configuration files for existing infrastructure that you want to start managing with Terraform?
When using a remote backend or terraform Cloud integration, where does Terraform save resource sate?
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.
terraform plan updates your state file.
What is the provider for the resource shown in the Exhibit?
resource " aws_vpc " " main " {
name = " test "
}
terraform apply is failing with the following error. What next step should you take to determine the root cause of the problem?
Error:
yaml
CopyEdit
Error loading state: AccessDenied: Access Denied
status code: 403, request id: 288766CE5CCA24A0, host id: web.example.com
What’s the proper syntax for the plan command?
A data source is shown in the exhibit below.
How do you reference the id attribute of this data source?
}
}
Where in your Terraform configuration do you specify remote state storage settings?
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?
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?
Module version is required to reference a module on the Terraform Module Registry.
As a developer, you want to ensure your plugins are up to date with the latest versions. Which Terraform command should you use?
If you don’t use the local Terraform backend, where else can Terraform save resource state?
How would you output returned values from a child module in the Terraform CLI output?
Which Terraform collection type should you use to store key/value pairs?
Which of the following is true about terraform apply?(Pick 2 correct responses)
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?
Terraform variables and outputs that set the description argument will store that description in the state file.
When does Sentinel enforce policy logic during a Terraform Cloud run?
What does terraform destroy do?
It is best practice to store secret data in the same version control repository as your Terraform configuration.
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?
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 need to destroy all of the resources in your Terraform workspace, except for aws_instance.ubuntu[1], which you want to keep. How can you tell Terraform to stop managing that specific resource without destroying it?
What is the purpose of the terraform.lock.hcl file in Terraform?
What task does the terraform import command perform?
How can you enable verbose logging to troubleshoot Terraform?
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?
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?
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?
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?
When should you run terraform init?
Only the user that generated a terraform plan may apply it.
terraform destroy is the only way to remove infrastructure with Terraform.
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.
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?
What does state looking accomplish?
If a module declares a variable with a default, that variable must also be defined within the module.
Where in your Terraform configuration do you specify a state backend?
What are some benefits of using Sentinel with Terraform Cloud/Terraform Cloud? Choose three correct answers.
When using Terraform to deploy resources into Azure, which scenarios are true regarding state files? (Choose two.)
A resource block is shown in the Exhibit section of this page. How would you reference the attribute name of this resource in HCL?
Setting the TF_LOG environment variable to DEBUG causes debug messages to be logged into stdout.
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?
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 can configure multiple cloud blocks in your Terraform configuration to connect your workspace to both HCP Terraform and your Terraform Enterprise instance.
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?
terraform apply will fail if you have not run terraform plan first to update the plan output.
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?
Which situation will return an error when you run terraform validate?
Which of the following is not a way to trigger terraform destroy?
Exhibit:
data " vsphere_datacenter " " dc " {}
resource " vsphere_folder " " parent " {
path = " Production "
type = " vm "
datacenter_id = _________
}
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 type of information does the Terraform Registry provide about the modules it hosts?
Which of these commands makes your code more human readable?
Which of the following methods, used to provision resources into a public cloud, demonstrates the concept of infrastructure as code?
Which type of block fetches or computes information for use elsewhere in a Terraform configuration?
A Terraform local value can reference other Terraform local values.
What command can you run to generateDOT (Graphviz)formatted data to visualize Terraform dependencies?
When should you use the force-unlock command?
Terraform installs its providers during which phase?
Which command must you run before you run a plan or apply for the first 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?
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.
Which of the following is not a valid source path for specifying a module?
Which option cannot be used to keep secrets out of Terraform configuration files?
Which backend does the Terraform CLI use by default?
When you include a module block in your configuration that references a module from the Terraform Registry, the " version " attribute is required.
Exhibit:
Root module configuration:
output " vnet_id " {
value = module.my_network.vnet_id
}
Error:
Error: Reference to undeclared output value
on main.tf line 12, in output " vnet_id " :
12: value = module.my_network.vnet_id
You are using a networking module in your Terraform configuration with the name my_network. Your root module includes the configuration shown. When you run terraform validate, you get the error shown. Which option would successfully retrieve this value from your networking module?
You just upgraded the version of a provider in an existing Terraform project. What do you need to do to install the new provider?
How can terraform plan aid in the development process?
Terraform encrypts sensitive values stored in your state file.
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.
Which of the following can you do with terraform plan? (Pick 2 correct responses)
The terraform output command shows outputs from child modules.
What is the workflow for deploying new infrastructure with Terraform?
Which of the following is not an action performed by terraform init?
Which of the following is availableonlyinHCP Terraform workspacesandnot in Terraform CLI?
Total 359 questions