HashiCorp Certified: Terraform Associate (004) (HCTA0-004) Questions and Answers
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?
Which command generates DOT (Document Template) formatted data to visualize Terraform dependencies?
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)
Terraform configuration can only call modules from the public registry.
Running terraform fmt without any flags in a directory with Terraform configuration files check the formatting of those files without changing their contents.
It is best practice to store secret data in the same version control repository as your Terraform configuration.
Which of these are features of HCP Terraform/Terraform Cloud? Pick the 2 correct responses below.
A provider configuration block is required in every Terraform configuration.
Example:

Terraform providers are always installed from the Internet.
terraform apply will fail if you have not run terraform plan first to update the plan output.
Which of the following should you add in the required_providers block to define a provider version constraint?
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?
Which two steps are required to provision new infrastructure in the Terraform workflow? Choose two correct answers.
Which of the following does terraform apply change after you approve the execution plan? (Choose two.)
Outside of the required_providers block, Terraform configurations always refer to providers by their local names.
Where in your Terraform configuration do you specify remote state storage settings?
How does Terraform determine dependencies between resources?
You can develop a custom provider to manage its resources using Terraform.
When using Terraform to deploy resources into Azure, which scenarios are true regarding state files? (Choose two.)
Which argument can you use toprevent unexpected updatesto a module ' s configuration when calling Terraform Registry modules?
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?
Terraform requires using a different provider for each cloud provider where you want to deploy resources.
What functionality do providers offer in Terraform?(Pick 3 correct responses)
What value does the Terraform Cloud private registry provide over the public Terraform Module Registry?
Which of the following is not a way to trigger terraform destroy?
Which of these are features of HCP Terraform/Terraform Cloud? (Pick the 2 correct responses)
Which of the following commands would you use to access all of the attributes and details of a resource managed by Terraform?
A terraform apply can not _________ infrastructure.
If you manually destroy infrastructure, what is the best practice reflecting this change in Terraform?
A senior admin accidentally deleted some of your cloud instances. What will Terraform do when you run terraform apply?
When you include a module block in your configuration that references a module from the Terraform Registry, the " version " attribute is required.
Terraform providers are part of the Terraform core binary.
Which of the following is not a benefit of adopting infrastructure as code?
terraform plan updates your state file.
Exhibit:
resource " azurerm_linux_web_app " " app " {
name = " example-app "
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
service_plan_id = azurerm_service_plan.plan.id
identity {
type = " UserAssigned "
identity_ids = [azurerm_user_assigned_identity.app.id]
}
}
resource " azurerm_role_assignment " " kv_access " {
scope = azurerm_key_vault.kv.id
role_definition_name = " Key Vault Secrets User "
principal_id = azurerm_user_assigned_identity.app.principal_id
}
Two resource blocks are shown: azurerm_linux_web_app and azurerm_role_assignment. When provisioned, the web app will use the role assignment during creation, so the role assignment must be created first. How do you ensure the azurerm_role_assignment resource is created first?
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?
What command can you run to generateDOT (Graphviz)formatted data to visualize Terraform dependencies?
The -refresh-only parameter will update your state file when used with terraform plan.
What is modified when executing Terraform inrefresh-only mode?
You should run terraform fnt to rewrite all Terraform configurations within the current working directory to conform to Terraform-style conventions.
How is terraform import run?
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?
Variables declared within a module are accessible outside of the module.
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.
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?
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?
When do changes invoked by terraform apply take effect?
Which of these are benefits of using Sentinel with HCP Terraform/Terraform Cloud? (Pick the 3 correct responses)
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?
A module can always refer to all variables declared in its parent module.
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
You cannot install third party plugins using terraform init.
Which of these commands makes your code more human readable?
Only the user that generated a terraform plan may apply it.
What does this code do?
terraform { required_providers { aws = " > = 3.0 " }}
Which command doesnotcause Terraform to refresh its state?
If you don’t use the local Terraform backend, where else can Terraform save resource state?
A child module can always access variables declared in its parent module.
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.
Terraform variable names are saved in the state file.
What is terraform plan -refresh-only intended to detect?
Define the purpose of state in Terraform.
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.
What is one disadvantage of using dynamic blocks in Terraform?
What functionality do providers offer in Terraform? (Pick the 3 correct responses below.)
What does terraform import do?
Any user can publish modules to the public Terraform Module Registry.
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 two steps are required to provision new infrastructure in the Terraform workflow? (Pick the 2 correct responses below.)
You corrected a typo in a resource name, changing it from aws_s3_bucket.photoes to aws_s3_bucket.photos. You want to update the Terraform state so that the existing resource is recognized under the new name, without destroying and recreating it. Which configuration should you use?
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.
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?
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?
Which backend does the Terraform CLI use by default?
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?
terraform validate uses provider APIs to verify your infrastructure settings.
Which method for sharing Terraform modules fulfills the following criteria:
Keeps the module configurations confidential within your organization.
Supports Terraform ' s semantic version constraints.
Provides a browsable directory of your modules.
What is the purpose of the terraform.lock.hcl file in Terraform?
Infrastructure as Code (laC) can be stored in a version control system along with application code.
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?
Which of the following locations can Terraform use as aprivate sourcefor modules?(Pick 2 correct responses)
Which is a benefit of using infrastructure as code (IaC) tools compared to native platform APIs?
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?
Setting the TF_LOG environment variable to DEBUG causes debug messages to be logged into stdout.
What is the name of the default file where Terraform stores the state?
Type your answer in the field provided. The text field is not case-sensitive and all variations of the correct answer are accepted.
What are some benefits of using Sentinel with Terraform Cloud/Terraform Cloud? Choose three correct answers.
Why would you use the -replace flag for terraform apply?
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?
When you use a remote backend that needs authentication, HashiCorp recommends that you:
How would you output returned values from a child module in the Terraform CLI output?
Which of the following can you do with terraform plan? (Pick 2 correct responses)
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?
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.
A Terraform local value can reference other Terraform local values.