HashiCorp Certified: Terraform Associate (004) (HCTA0-004) Questions and Answers
When using multiple configurations of the same Terraform provider, what meta-argument must you include in any non-default provider configurations?
What task does the terraform import command perform?
You cannot install third party plugins using terraform init.
Which statements are true about terraform apply? (Choose TWO correct answers)
Which syntax check returns an error when you run terraform validate?
Which of these ate secure options for storing secrets for connecting to a Terraform remote backend? Choose two correct answers.
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.
Which type of block fetches or computes information for use elsewhere in a Terraform configuration?
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?
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?
How does Terraform manage most dependencies between resources?
Does terraform init create an example main.tf file in the current directory?
Terraform configuration (including any module references) can contain only one Terraform provider type.
Which of these statements about Terraform Cloud workspaces is false?
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?
Where in your Terraform configuration do you specify remote state storage settings?
Which of the following command would be use to access all of the attributes and details of a resource managed by Terraform?
Which of these workflows is only enabled by the use of Infrastructure as Code?
Infrastructure as Code (laC) can be stored in a version control system along with application code.
When you run terraform apply, the Terraform CLI will print output values from both the root module and any child modules.
Running terraform fmt without any flags in a directory with Terraform configuration files check the formatting of those files without changing their contents.
Which are benefits of migrating from a local state backend to a remote backend? (Pick the 2 correct responses below.)
What information does the public Terraform Module Registry automatically expose about published modules?
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 of the following is not a valid Terraform collection type?
What is the Terraform style convention for indenting a nesting level compared to the one above it?
You’ve updated your Terraform configuration, and you need to preview the proposed changes to your infrastructure. Which command should you run?
Which of these are features of Terraform Cloud? Choose two correct answers.
What does terraform import do?
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?
Terraform encrypts sensitive values stored in your state file.
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?
After creating a new Terraform configuration, your configuration passes terraform validate but returns an “Access Denied” error from the cloud provider when running terraform plan.
Why did terraform validate not catch this issue?
As a developer, you want to ensure your plugins are up to date with the latest versions. Which Terraform command should you use?
You manage two workspaces in your HCP Terraform organization. The first workspace manages your network configuration. The second workspace manages your compute resources and retrieves values from the networking workspace.
What HCP Terraform feature lets you run an apply operation on the compute workspace every time you update the networking workspace?
Which option cannot be used to keep secrets out of Terraform configuration files?
Before you can use a remote backend, you must first execute terra-form init.
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 features do HCP Terraform workspaces provide that are not available in Terraform Community Edition? (Pick the 3 correct responses below.)
You ate making changes to existing Terraform code to add some new infrastructure. When is the best time to run terraform validate?
Which Terraform collection type should you use to store key/value pairs?
Why would you use the -replace flag for terraform apply?
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 of the following isnotan advantage of using Infrastructure as Code (IaC) operations?
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?
You are responsible for a set of infrastructure that is managed by two workspaces: example-network and example-compute. The example-compute workspace uses data from output values configured in the example-network workspace and must be deployed afterward. Currently, this is a manual process:
An operator deploys changes to the example-network workspace.
They manually copy the output values from the example-network workspace to input variables configured for the example-compute workspace.
They deploy the example-compute workspace.
Which HCP Terraform features can you use to automate this process?
Pick the two correct responses below.
When does Terraform create the .terraform.lock.hc1 file?
Which statement describes a goal of Infrastructure as Code (IaC)?
Which of the following arguments are required when declaring a Terraform output?
Which of these are features of HCP Terraform/Terraform Cloud? Pick the 2 correct responses below.
Terraform variables and outputs that set the description argument will store that description in the state file.
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.
You can define multiple backend blocks in your Terraform configuration to store your state in multiple locations.
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?
When using Terraform to deploy resources into Azure, which scenarios are true regarding state files? (Choose two.)
What are some benefits of using Sentinel with Terraform Cloud/Terraform Cloud? Choose three correct answers.
You can execute terraform fmt to standardize all Terraform configurations within the current working directory to Terraform’s canonical format and style.
All standard backend types support state locking, and remote operations like plan, apply, and destroy.
You can configure multiple cloud blocks in your Terraform configuration to connect your workspace to both HCP Terraform and your Terraform Enterprise instance.
When should you run terraform init?
A module can always refer to all variables declared in its parent module.
You can install community and partner plugins using terraform init.
Which argument can you use toprevent unexpected updatesto a module ' s configuration when calling Terraform Registry modules?
When you use a backend that requires authentication, it is best practice to:
Which is not a benefit of adopting IaC (Infrastructure as Code)?
Which are examples of infrastructure as code? Choose two correct answers.
What is the primary purpose of IaC (Infrastructure as Code)?
How can you configure a Terraform workspace to store its state remotely?
What does this code do?
terraform { required_providers { aws = " > = 3.0 " }}
Which of these actions will prevent two Terraform runs from changing the same state file at the same time?
Which provider authentication method prevents credentials from being stored in the state file?
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.
The Terraform binary version and provider versions must match each other in a single configuration.
The_________determines how Terraform creates, updates, or delete resources.
If you manually destroy infrastructure, what is the best practice reflecting this change in Terraform?
A Terraform local value can reference other Terraform local values.
Module variable assignments are inherited from the parent module and you do not need to explicitly set them.
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?
Only the user that generated a plan may apply it.
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)
Variables declared within a module are accessible outside of the module.
Which is the best way to specify a tag of v1.0.0 when referencing a module stored in Git (for example.
What functionality do providers offer in Terraform?(Pick 3 correct responses)
Changing the Terraform backend from the default " local " backend to a different one after performing your first terrafom apply is:
Your team often uses API calls to create and manage cloud infrastructure. In what ways does Terraform differ from conventional infrastructure management approaches?
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 parameters does the import block require? (Pick the 2 correct responses below.)
The public Terraform Module Registry is free to use.
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?
Terraform stores the value of an output in its state file, even if the sensitive argument is set to true.
What does the default " local " Terraform backend store?
terraform validate uses provider APIs to verify your infrastructure settings.
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?
Outside of the required_providers block, Terraform configurations always refer to providers by their local names.
Which of these are benefits of using Sentinel with HCP Terraform/Terraform Cloud? (Pick the 3 correct responses)
What does Terraform not reference when running a terraform apply -refresh-only ?
The terraform output command shows outputs from child modules.
When you use a backend that requires authentication, it is best practice to:
Terraform requires using a different provider for each cloud provider where you want to deploy resources.
Module version is required to reference a module on the Terraform Module Registry.
Which of the following does HCP Terraform perform during a health assessment for a workspace?
Which task does terraform init not perform?
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?
Which of the following is availableonlyinHCP Terraform workspacesandnot in Terraform CLI?
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?
What is an advantage of immutable infrastructure?