Terraform-Associate-004 HashiCorp Certified: Terraform Associate (004) (HCTA0-004) Questions and Answers
A senior admin accidentally deleted some of your cloud instances. What will Terraform do when you run terraform apply?
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?
As a developer, you want to ensure your plugins are up to date with the latest versions. Which Terraform command should you 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:
You can configure multiple cloud blocks in your Terraform configuration to connect your workspace to both HCP Terraform and your Terraform Enterprise instance.
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)
You need to determine from which paths Terraform is loading the providers referenced in your *.tf files.
How can you enable additional logging to see this information?
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?
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 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.
What Terraform command always causes a state file to be updated with changes that might have been made outside of Terraform?
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 type of information can be found on the Terraform Registry when using published modules?
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 of the following should you add in the required_providers block to define a provider version constraint?
Terraform stores the value of an output in its state file, even if the sensitive argument is set to true.
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?
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?
When should you write Terraform configuration files for existing infrastructure that you want to start managing with Terraform?
You can access state stored with the local backend by using terraform_remote_state data source.
A Terraform output that sets the " sensitive " argument to true will not store that value in the state file.
Which of these statements about HCP Terraform/Terraform Cloud workspaces is false?
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?
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?
A provider configuration block is required in every Terraform configuration.
Example:
Which of the following can you do with terraform plan? (Pick 2 correct responses)
Once you configure a new Terraform backend with a terraform code block, which command(s) should you use to migrate the state file?
When you initialize Terraform, where does it cache modules from the public Terraform Registry?
Which two steps are required to provision new infrastructure in the Terraform workflow? (Pick the 2 correct responses below.)
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.
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?
Where does HashiCorp recommend you store API tokens and other secrets within your team ' s Terraform workspaces?
Pick three correct responses below:
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.
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 methods, used to provision resources into a public cloud, demonstrates the concept of infrastructure as code?
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 functionality do providers offer in Terraform? (Pick the 3 correct responses below.)
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.
You just upgraded the version of a provider in an existing Terraform project. What do you need to do to install the new provider?
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 argument can you use toprevent unexpected updatesto a module ' s configuration when calling Terraform Registry modules?
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?
When using a remote backend or terraform Cloud integration, where does Terraform save resource sate?
Outside of the required_providers block, Terraform configurations always refer to providers by their local names.
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 using multiple configuration of the same Terraform provider, what meta-argument must you include in any non-default provider configurations?
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?
Which of the following arguments are required when declaring a Terraform output?
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?
When you include a module block in your configuration that references a module from the Terraform Registry, the " version " attribute is required.
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?
INcheck block ' s assertion fails, Terraform blocks the current operation from executing.
Which command should you run to check if all code in a Terraform configuration that references multiple modules is properly formatted without making changes?
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 the provider for the resource shown in the Exhibit?
resource " aws_vpc " " main " {
name = " test "
}
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?
What does Terraform not reference when running a terraform apply -refresh-only ?
If you don’t use the local Terraform backend, where else can Terraform save resource state?
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?
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?
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 these actions are forbidden when the Terraform state file is locked? (Pick the 3 correct responses)
What kind of configuration block will manage an infrastructure object with settings specified within the block?
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?
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?
How do you specify a module’s version when publishing it to the public terraform Module Registry?
What command can you run to generateDOT (Graphviz)formatted data to visualize Terraform dependencies?
A resource block is shown in the Exhibit space of this page. What is the Terraform resource name of the resource block?