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.
The public Terraform Module Registry is free to use.
What value does the Terraform Cloud private registry provide over the public Terraform Module Registry?
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?
Using the terraform state rm command against a resource will destroy it.
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?
Which of the following statements about Terraform modules is not true?
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?
Which of these is true about Terraform ' s plugin-based architecture?
Which of the following does terraform apply change after you approve the execution plan? (Choose two.)
A Terraform local value can reference other Terraform local values.
IN check block ' s assertion fails, Terraform blocks the current operation from executing.
Which of the following is not a way to trigger terraform destroy?
What is the provider for this resource?
How can terraform plan aid in the development process?
When should you write Terraform configuration files for existing infrastructure that you want to start managing with 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?
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.
You need to deploy resources into two different regions in the same Terraform configuration using the block shown in the exhibit below.
What do you need to add to the provider configuration to deploy the resource to the us-west-2 AWS region?
A
B.

C.

D.

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?
How does Terraform manage most dependencies between resources?
Terraform configuration can only import modules from the public registry.
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?
How could you reference an attribute from the vsphere_datacenter data source for use with the datacenter_id argument within the vsphere_folder resource in the following configuration?
You just upgraded the version of a provider in an existing Terraform project. What do you need to do to install the new provider?
Select the command that doesn’t cause Terraform to refresh its state.
The_________determines how Terraform creates, updates, or delete resources.
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?
Outside of the required_providers block, Terraform configurations always refer to providers by their local names.
Your security team scanned some Terraform workspaces and found secrets stored in plaintext in state files. How can you protect that data?
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)
As a member of an operations team that uses infrastructure as code (lac) practices, you are tasked with making a change to an infrastructure stack running in a public cloud. Which pattern would follow laC best practices for making a change?
Which parameters does terraform import require? Choose two correct answers.
Only the user that generated a plan may apply it.
Which command(s) adds existing resources in a public cloud into Terraform state?
Terraform providers are always installed from the Internet.
What type of block is used to construct a collection of nested configuration blocks?
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?
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)
You can define multiple backend blocks in your Terraform configuration to store your state in multiple locations.
What are some benefits of using Sentinel with Terraform Cloud/Terraform Cloud? Choose three correct answers.
Which of the following should you add in the required_providers block to define a provider version constraint?
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?
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?
What is the purpose of the .terraform directory in a Terraform workspace?
All modules published on the official Terraform Module Registry have been verified by HasihCorp.
Your team adopts AWS CloudFormation as the standardized method for provisioning public cloud resources. Which scenario presents a challenge for your team?
How would you reference the volume IDs associated with the ebs_block_device blocks in this configuration?

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 delete the VM using the cloud provider console, then run terraform apply again without changing any Terraform code?
HashiCorp Configuration Language (HCL) supports user-denned functions.
Which parameters does the import block require? (Pick the 2 correct responses below.)
Which command lets you experiment with terraform expressions?
Which syntax check returns an error when you run terraform validate ?
Which of the following is not a benefit of adopting infrastructure as code?
When you use a remote backend that needs authentication, HashiCorp recommends that you:
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?
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?
What does Terraform use the .terraform.lock.hc1 file for?
You are updating a child module with the resource block shown in the exhibit below. The public_ip attribute of the resource needs to be accessible to the parent module.
Exhibit:
resource " aws_instance " " example " {
ami = " ami-0a123456789abcdef "
instance_type = " t3.micro "
}
How do you meet this requirement?
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?
Variables declared within a module are accessible outside of the module.
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?
When using a remote backend or terraform Cloud integration, where does Terraform save resource sate?
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?
Which are forbidden actions when the terraform state file is locked? Choose three correct answers.
_______backends support state locking.
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 provider authentication method prevents credentials from being stored in the state file?
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?
A resource block is shown in the Exhibit space of this page. What is the Terraform resource name of the resource block?
You ' re writing a Terraform configuration that needs to read input from a local file called id_rsa.pub. Which built-in Terraform function can you use to import the file ' s contents as a string?
Where in your Terraform configuration do you specify a state backend?
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?
The Terraform binary version and provider versions must match each other in a single configuration.
You’ve updated your Terraform configuration, and you need to preview the proposed changes to your infrastructure. Which command should you run?
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)
Which of the following isnotan advantage of using Infrastructure as Code (IaC) operations?
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 apply can not _________ infrastructure.
Which of the following arguments are required when declaring a Terraform output?
How does Terraform determine dependencies between resources?
In a Terraform Cloud workpace linked to a version control repository speculative plan rum start automatically commit changes to version control.
You ' re writing a Terraform configuration that needs to read input from a local file called id_rsa.pub . Which built-in Terraform function can you use to import the file ' s contents as a string?
Which of the following is not an action performed by terraform init?
Which type of block fetches or computes information for use elsewhere in a Terraform configuration?
Which of these actions will prevent two Terraform runs from changing the same state file at the same time?
Which of the following is not a valid Terraform variable type?
You can develop a custom provider to manage its resources using Terraform.
Which of the following methods, used to provision resources into a public cloud, demonstrates the concept of infrastructure as code?
A module can always refer to all variables declared in its parent module.
You modified your Terraform configuration to fix a typo in the resource ID by renaming it from photoes to photos. What configuration will you add to update the resource ID in state without destroying the existing resource?
Original configuration:
resource " aws_s3_bucket " " photoes " {
bucket_prefix = " images "
}
Updated configuration:
resource " aws_s3_bucket " " photos " {
bucket_prefix = " images "
}
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)
What is one disadvantage of using dynamic blocks in Terraform?
What’s the proper syntax for the plan command?
How would you output returned values from a child module in the Terraform CLI output?
What is the Terraform style convention for indenting a nesting level compared to the one above it?
A resource block is shown in the Exhibit space of this page. What is the Terraform resource name of that resource block?
Which two steps are required to provision new infrastructure in the Terraform workflow? (Pick the 2 correct responses below.)
Which of these commands makes your code more human readable?
Your team adopts AWS CloudFormation as the standardized method for provisioning public cloud resources.
Which scenario presents a challenge for your team?
Terraform stores the value of an output in its state file, even if the sensitive argument is set to true.
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.
You are updating a child module with the resource block shown in the exhibit below. The public_ip attribute of the resource needs to be accessible to the parent module.
Exhibit:
resource " aws_instance " " example " {
ami = " ami-0a123456789abcdef "
instance_type = " t3.micro "
}
How do you meet this requirement?
Which backend does the Terraform CLI use by default?
What type of information can be found on the Terraform Registry when using published modules?
How is terraform import run?
Outside of the required_providers block, Terraform configurations always refer to providers by their local names.
The public Terraform Module Registry is free to use.
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 these ate features of Terraform Cloud? Choose two correct answers.
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?
How does the use of Infrastructure as Code (IaC) enhance the reliability of your infrastructure?
Pick the two correct responses below.
You modified your Terraform configuration to fix a typo in the resource ID by renaming it from photoes to photos. What configuration will you add to update the resource ID in state without destroying the existing resource?
Original configuration:
resource " aws_s3_bucket " " photoes " {
bucket_prefix = " images "
}
Updated configuration:
resource " aws_s3_bucket " " photos " {
bucket_prefix = " images "
}
Which of the following should you put into the required_providers block?
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 delete the VM using the cloud provider console, then run terraform apply again without changing any Terraform code?
A child module can always access variables declared in its parent module.
Your Terraform configuration declares a variable. You want to enforce that its value meets your specific requirements, and you want to block the Terraform operation if it does not. What should you add to your configuration?
If you update the version constraint in your Terraform configuration, Terraform will update your lock file the next time you run terraform Init.
Terraform can only manage resource dependencies if you set them explicitly with the depends_on argument.
Changing the Terraform backend from the default " local " backend to a different one after performing your first terrafom apply is:
What is modified when executing Terraform inrefresh-only mode?
How would you output returned values from a child module in the Terraform CLI output?
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 information does the public Terraform Module Registry automatically expose about published modules?
Which of the following methods, used to provision resources into a public cloud, demonstrates the concept of infrastructure as code?
A Terraform output that sets the " sensitive " argument to true will not store that value in the state file.
terraform validate confirms thesyntaxof Terraform files.
The terraform output command shows outputs from child modules.
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?
What is the primary purpose of IaC (Infrastructure as Code)?
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.
A Terraform provider is NOT responsible for:
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 of the following does HCP Terraform perform during a health assessment for a workspace?
Why is it considered important to treat your Terraform state file as sensitive?
A Terraform backend determines how Terraform loads state and stores updates when you execute which command?
When you include a module block in your configuration that references a module from the Terraform Registry, the " version " attribute is required.
You can install community and partner plugins using terraform init.
terraform init retrieves and caches the configuration for all remote modules.
What does terraform destroy do?
Terraform variable names are saved in the 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.
Once you configure a new Terraform backend with a terraform code block, which command(s) should you use to migrate the state file?
Which command lets you experiment with terraform expressions?
You have to initialize a Terraform backend before it can be configured.
All standard backend types support state locking, and remote operations like plan, apply, and destroy.
A provider configuration block is required in every Terraform configuration.
Example:
What is the workflow for deploying new infrastructure with Terraform?
One remote backend configuration always maps to a single remote workspace.
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)
Which argument can you use toprevent unexpected updatesto a module ' s configuration when calling Terraform Registry modules?
You can develop a custom provider to manage its resources using Terraform.
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?
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?
Which of the following is not a key principle of infrastructure as code?
Which are forbidden actions when the terraform state file is locked? Choose three correct answers.
Only the user that generated a plan may apply it.
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 of the following does terraform apply change after you approve the execution plan? (Choose two.)
Only the user that generated a terraform plan may apply it.
Which of the following can you do with terraform plan?
Pick the two correct responses below.
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 command(s) adds existing resources in a public cloud into Terraform state?
terraform validate reports syntax check errors for which of the following?
Which type of information does the Terraform Registry provide about the modules it hosts?
Which is a recommended way to share Terraform state across teams?
Which is a benefit of the Terraform state file?
Which command add existing resources into Terraform state?
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)
Why would you use the -replace flag for terraform apply?
Which parameters does terraform import require? Choose two correct answers.
Why is it important to treat your Terraform state file as sensitive?
Which command generates DOT (Document Template) formatted data to visualize Terraform dependencies?
Which command doesnotcause Terraform to refresh its state?
_______backends support state locking.
Which task does terraform init not perform?
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?
What’s the proper syntax for the plan command?
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?
Which of the following should you add in the required_providers block to define a provider version constraint?
Your team often uses API calls to create and manage cloud infrastructure. In what ways does Terraform differ from conventional infrastructure management approaches?
What Terraform command always causes a state file to be updated with changes that might have been made outside of Terraform?
terraform plan updates your state file.
Terraform installs its providers during which phase?
Terraform requires using a different provider for each cloud provider where you want to deploy resources.
Which of the following command would be use to access all of the attributes and details of a resource managed by Terraform?
What are some benefits of using Sentinel with Terraform Cloud/Terraform Cloud? Choose three correct answers.
HashiCorp Configuration Language (HCL) supports user-denned functions.
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?
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.
Using the terraform state rm command against a resource will destroy it.
Running terraform fmt without any flags in a directory with Terraform configuration files check the formatting of those files without changing their contents.
Where in your Terraform configuration do you specify remote state storage settings?
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 the following ate advantages of using infrastructure as code (laC) instead of provisioning with a graphical user interface (GUI)? Choose two correct answers.
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 providers are always installed from the Internet.
What is a key benefit of the Terraform state file?
How can you configure a Terraform workspace to store its state remotely?
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?
Define the purpose of state in Terraform.
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?
3 Months Free Update
3 Months Free Update
3 Months Free Update