HashiCorp Terraform-Associate-004 HashiCorp Certified: Terraform Associate (004) (HCTA0-004) Exam Practice Test
Total 366 questions
HashiCorp Certified: Terraform Associate (004) (HCTA0-004) Questions and Answers
When does Terraform create the .terraform.lock.hc1 file?
When you run terraform apply -refresh-only, which of the following is not consulted by Terraform to update the state file?
Which task does terraform init not perform?
You’ve updated your Terraform configuration, and you need to preview the proposed changes to your infrastructure. Which command should you run?
Which of the following module source paths does not specify a remote module?
You can configure Terraform to log to a file using the TF_LOG environment variable.
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?
Only the user that generated a plan may apply it.
Which features do HCP Terraform workspaces provide that are not available in Terraform Community Edition? (Pick the 3 correct responses below.)
Terraform requires using a different provider for each cloud provider where you want to deploy resources.
Which command(s) adds existing resources in a public cloud into Terraform state?
When using a remote backend or terraform Cloud integration, where does Terraform save resource sate?
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 created infrastructure outside the Terraform workflow that you now want to manage using Terraform. Which command brings the infrastructure into Terraform state?
Which are examples of infrastructure as code? Choose two correct answers.
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?
A Terraform provider is NOT responsible for:
Which Terraform collection type stores values as key/value pairs?
Your team adopts AWS CloudFormation as the standardized method for provisioning public cloud resources. Which scenario presents a challenge for your team?
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)
When using Terraform to deploy resources into Azure, which scenarios are true regarding state files? (Choose two.)
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?
You can execute terraform fmt to standardize all Terraform configurations within the current working directory to Terraform’s canonical format and style.
Does terraform init create an example main.tf file in the current directory?
When declaring a variable, setting the sensitive argument to true will prevent the value from being stored in the state file.
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?
When should you use the terraform force-unlock command?
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 is the purpose of the .terraform directory in a Terraform workspace?
Which is a recommended way to share Terraform state across teams?
You just scaled your VM infrastructure and realize you set the count variable to the wrong value. You correct the value and save your change. What must you do next to make your infrastructure match your configuration?
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.
The Terraform binary version and provider versions must match each other in a single configuration.
When do you need to explicitly execute Terraform in refresh-only mode?
terraform destroy is the only way to remove infrastructure.
Where in your Terraform configuration do you specify remote state storage settings?
You ate making changes to existing Terraform code to add some new infrastructure. When is the best time to run terraform validate?
What value does the Terraform Cloud private registry provide over the public Terraform Module Registry?
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.
Only the user that generated a terraform plan may apply it.
What is the purpose of the terraform.lock.hcl file in Terraform?
You should run terraform fnt to rewrite all Terraform configurations within the current working directory to conform to Terraform-style conventions.
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?

A resource block is shown in the Exhibit space of this page. What is the provider for this resource?
Which parameters does terraform import require? Choose two correct answers.
Terraform installs its providers during which phase?
What type of block is used to construct a collection of nested configuration blocks?
When you use a backend that requires authentication, it is best practice to:
What information does the public Terraform Module Registry automatically expose about published modules?
Which command add existing resources into Terraform state?
What is the primary purpose of IaC (Infrastructure as Code)?
You’ve just finished refactoring part of your Terraform workspace’s configuration to use a module to manage some of your resources. When you plan your changes, you notice that Terraform will destroy and recreate the affected resources. Doing so could cause unintended downtime in the application your workspace manages. What supported approach should you take to complete the refactor without destroying and recreating your resources?
A Terraform backend determines how Terraform loads state and stores updates when you execute which command?
Your team is collaborating on infrastructure using Terraform and wants to format code to follow Terraform language style conventions. How can you update your code to meet these requirements?
You have just developed a new Terraform configuration for two virtual machines with a cloud provider. You would like to create the infrastructure for the first time.
Which Terraform command should you runfirst?
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)
Why is it important to treat your Terraform state file as sensitive?
Which of the following should you add in the required_providers block to define a provider version constraint?
Terraformrequiresthe Go runtime as a prerequisite for installation.
The terraform output command shows outputs from child modules.
Terraform configuration can only import modules from the public registry.
What type of information can be found on the Terraform Registry when using published modules?
Before you can use a new backend or HCP Terraform/Terraform Cloud integration, you must first execute terraform init.
How is terraform import run?
Your team adopts AWS CloudFormation as the standardized method for provisioning public cloud resources.
Which scenario presents a challenge for your team?
Which of these commands makes your code more human readable?
Which is not a benefit of adopting IaC (Infrastructure as Code)?
When you include a module block in your configuration that references a module from the Terraform Registry, the " version " attribute is required.
Your configuration contains a module block that references a module from the Terraform Registry and sets the version argument to 1.0. You just published a new version of the module and updated your configuration to point to version 1.1.
Which command must be run to install the new version?
Terraform configuration (including any module references) can contain only one Terraform provider type.
Why does this backend configuration not follow best practices?

You must use different Terraform commands depending on the cloud provider you use.
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?
Your security team scanned some Terraform workspaces and found secrets stored in plaintext in state files. How can you protect that data?
A module block used in your configuration is shown in the exhibit. You have been asked to update the version of this module from 4.2.1 to 5.0.0.
Exhibit:
module " compute " {
source = " Azure/compute/azurerm "
version = " 4.2.1 "
}
Which two steps must you take to accomplish this?
Why would you use the -replace flag for terraform apply?
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?
One remote backend configuration always maps to a single remote workspace.
Which configuration consistency errors does terraform validate report?
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.
terraform apply will fail if you have not run terraform plan first to update the plan output.
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?
Module variable assignments are inherited from the parent module and you do not need to explicitly set them.
You have a simple Terraform configuration containing one virtual machine (VM) in a cloud provider. You run terraform apply and the VM is created successfully. What will happen if you terraform apply again immediately afterward without changing any Terraform code?
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 of the following commands would you use to access all of the attributes and details of a resource managed by Terraform?
What is the Terraform style convention for indenting a nesting level compared to the one above it?
What is the primary purpose of Infrastructure as Code (IaC)?
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?
What is one disadvantage of using dynamic blocks in Terraform?
When using multiple configurations of the same Terraform provider, what meta-argument must you include in any non-default provider configurations?
What’s the proper syntax for the plan command?
How can you configure a Terraform workspace to store its state remotely?
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 module can always refer to all variables declared in its parent module.
What is modified when executing Terraform inrefresh-only mode?
Which of the following is not a valid source path for specifying a module?
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 is a benefit of the Terraform state file?
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
Which command must you first run before performing further Terraform operations in a working directory?
Which of the following is not a benefit of adopting infrastructure as code?
How would you reference the volume IDs associated with the ebs_block_device blocks in this configuration?

Module version is required to reference a module on the Terraform Module Registry.
terraform validate reports syntax check errors for which of the following?
What kind of configuration block will create an infrastructure object with settings specified within the block?
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?
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.
Total 366 questions