HashiCorp Terraform-Associate-004 HashiCorp Certified: Terraform Associate (004) (HCTA0-004) Exam Practice Test
Total 318 questions
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?
Your security team scanned some Terraform workspaces and found secrets stored in plaintext in state files. How can you protect that data?
What is a key benefit of the Terraform state file?
As a developer, you want to ensure your plugins are up to date with the latest versions. Which Terraform command should you use?
Terraform configuration can only call modules from the public registry.
Which of the following is availableonlyinHCP Terraform workspacesandnot in Terraform CLI?
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?
What information does the public Terraform Module Registry automatically expose about published modules?
Terraform providers are always installed from the Internet.
A child module can always access variables declared in its parent module.
If a module declares a variable without a default value, you must pass the value of the variable within the module block when you call the module in your configuration.
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?
A Terraform local value can reference other Terraform local values.
You can develop a custom provider to manage its resources using 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?
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)?
Which of the following isnotan advantage of using Infrastructure as Code (IaC) operations?
Which is a benefit of using infrastructure as code (IaC) tools compared to native platform APIs?
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?
Which situation will return an error when you run terraform validate?
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?
Where in your Terraform configuration do you specify a state backend?
What is the purpose of the .terraform directory in a Terraform workspace?
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?
terraform plan updates your state file.
Which task does terraform init not perform?
Terraform variables and outputs that set the description argument will store that description in the state file.
How would you reference the volume IDs associated with the ebs_block_device blocks in this configuration?

Which is a benefit of the Terraform state file?
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?
Which of these statements about HCP Terraform/Terraform Cloud workspaces is false?
Which of the following methods, used to provision resources into a public cloud, demonstrates the concept of infrastructure as code?
Which of the following should you put into the required_providers block?
What value does the Terraform Cloud private registry provide over the public Terraform Module Registry?
Outside of the required_providers block, Terraform configurations always refer to providers by their local names.
Which task does terraform init not perform?
Which statement describes a goal of Infrastructure as Code (IaC)?
Which of these are benefits of using Sentinel with HCP Terraform/Terraform Cloud? (Pick the 3 correct responses)
Which of the following is not a valid Terraform collection type?
Which type of block fetches or computes information for use elsewhere in a Terraform configuration?
You used Terraform to create an ephemeral development environment in the cloud 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 the resources that will be deleted? (Pick the 2 correct responses)
When should you run terraform init?
Which of these are features of HCP Terraform/Terraform Cloud? (Pick the 2 correct responses)
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 team adopts AWS CloudFormation as the standardized method for provisioning public cloud resources. Which scenario presents a challenge for your team?
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?
What is a Terraform provider not responsible for?
When does Terraform create the .terraform.lock.hc1 file?
Where does HashiCorp recommend you store API tokens and other secrets within your team’s Terraform workspaces?
Pick the three correct responses below.
What is the Terraform style convention for indenting a nesting level compared to the one above it?
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?
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?
terraform init creates an example main.tf file in the current directory.
Which of the following can you do with terraform plan?
Pick the two correct responses below.
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.
Exhibit:
resource " aws_instance " " example " {
ami = " ami-0a123456789abcdef "
instance_type = " t3.micro "
}
You are updating a child module with the resource block shown in the exhibit. The public_ip attribute of the resource needs to be accessible to the parent module. How do you meet this requirement?
When you run terraform apply, the Terraform CLI will print output values from both the root module and any child modules.
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?
How can a ticket-based system slow down infrastructure provisioning and limit the ability to scale? Choose two correct answers.
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?
What does Terraform not reference when running a terraform apply -refresh-only ?
One remote backend configuration always maps to a single remote workspace.
When you use a backend that requires authentication, it is best practice to:
Only the user that generated a plan may apply it.
A resource block is shown in the Exhibit space of this page. What is the Terraform resource name of that resource block?
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?
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)
You have declared a variable called var.list which is a list of objects that all have an attribute id . Which options will produce a list of the IDs? Choose two correct answers.
If you manually destroy infrastructure, what is the best practice reflecting this change in Terraform?
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?
When you initialize Terraform, where does it cache modules from the public Terraform Registry?
You can reference a resource created with for_each using a Splat ( *) expression.
Which configuration consistency errors does terraform validate report?
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?
When do you need to explicitly execute Terraform in refresh-only mode?
How does Terraform determine dependencies between resources?
Where does the Terraform local backend store its state?
Which of these are features of HCP Terraform/Terraform Cloud? Pick the 2 correct responses below.
Which of the following is true about terraform apply?(Pick 2 correct responses)
Why would you use the -replace flag for terraform apply?
A resource block is shown in the Exhibit section of this page. How would you reference the attribute name of this resource in HCL?
What type of information can be found on the Terraform Registry when using published modules?
Which of the following locations can Terraform use as aprivate sourcefor modules?(Pick 2 correct responses)
What is terraform plan -refresh-only intended to detect?
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.
Terraform encrypts sensitive values stored in your state file.
Module variable assignments are inherited from the parent module and you do not need to explicitly set them.
What is the purpose of state locking in a remote backend?
It is best practice to store secret data in the same version control repository as your Terraform configuration.
If a module declares a variable with a default, that variable must also be defined within the module.
You must use different Terraform commands depending on the cloud provider you use.
What is the provider for this resource?
You are writing a child Terraform module that provisions an AWS instance. You want to reference the IP address returned by the child module in the root configuration. You name the instance resource " main ' .
Which of these is the correct way to define the output value?
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)
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?
Total 318 questions