HashiCorp TA-002-P HashiCorp Certified: Terraform Associate Online Training
HashiCorp TA-002-P Online Training
The questions for TA-002-P were last updated at Jan 13,2025.
- Exam Code: TA-002-P
- Exam Name: HashiCorp Certified: Terraform Associate
- Certification Provider: HashiCorp
- Latest update: Jan 13,2025
Which option can not be used to keep secrets out of Terraform configuration files?
- A . A Terraform provider
- B . Environment variables
- C . A -var flag
- D . secure string
A
Explanation:
Reference: https://secrethub.io/blog/secret-management-for-terraform/
Why would you use the terraform taint command?
- A . When you want to force Terraform to destroy a resource on the next apply
- B . When you want to force Terraform to destroy and recreate a resource on the next apply
- C . When you want Terraform to ignore a resource on the next apply
- D . When you want Terraform to destroy all the infrastructure in your workspace
B
Explanation:
The terraform taint command manually marks a Terraform-managed resource as tainted, forcing it to be destroyed and recreated on the next apply.
Reference: https://www.terraform.io/docs/cli/commands/taint.html
Setting the TF_LOG environment variable to DEBUG causes debug messages to be logged into syslog.
- A . True
- B . False
B
Explanation:
TF_LOG_PATH IS NOT REQUIRED, in the docs, they do not mention HAVE TO SET
TF_LOG_PATH, it is optional, therefore without TF_LOG_PATH will cause detailed logs to appear on stderr.
https://www.computerhope.com/jargon/s/stderr.htm#:~:text=Stderr%2C%20also%20known%20as%20standard,defaults%20to%20the%20user’s%20screen.
A fellow developer on your team is asking for some help in refactoring their Terraform code. As part of their application’s architecture, they are going to tear down an existing deployment managed by Terraform and deploy new. However, there is a server resource named aws_instance.ubuntu[1] they would like to keep to perform some additional analysis.
What command should be used to tell Terraform to no longer manage the resource?
- A . terraform apply rm aws_instance.ubuntu[1]
- B . terraform state rm aws_instance.ubuntu[1]
- C . terraform plan rm aws_instance.ubuntu[1]
- D . terraform delete aws_instance.ubuntu[1]
B
Explanation:
"You can use terraform state rm in the less common situation where you wish to remove a binding to an existing remote object without first destroying it, which will effectively make Terraform "forget" the object while it continues to exist in the remote system." https://www.terraform.io/cli/commands/state/rm
Which two steps are required to provision new infrastructure in the Terraform workflow? (Choose two.)
- A . Destroy
- B . Apply
- C . Import
- D . Init
- E . Validate
B,D
Explanation:
Reference: https://www.terraform.io/guides/core-workflow.html
Which of the following is the correct way to pass the value in the variable num_servers into a module with the input servers?
- A . servers = num_servers
- B . servers = variable.num_servers
- C . servers = var(num_servers)
- D . servers = var.num_servers
D
Explanation:
"Within the module that declared a variable, its value can be accessed from within expressions as var.<NAME>, where <NAME> matches the label given in the declaration block:
Note: Input variables are created by a variable block, but you reference them as attributes on an object named var."
https://www.terraform.io/language/values/variables#using-input-variable-values
Which statement describes a goal of infrastructure as code?
- A . An abstraction from vendor specific APIs
- B . Write once, run anywhere
- C . A pipeline process to test and deliver software
- D . The programmatic configuration of resources
D
Explanation:
The purpose of infrastructure as code is to enable developers or operations teams to automatically manage, monitor and provision resources, rather than manually configure discrete hardware devices and operating systems. Infrastructure as code is sometimes referred to as programmable or software-defined infrastructure.
What value does the Terraform Cloud/Terraform Enterprise private module registry provide over the public Terraform Module Registry?
- A . The ability to share modules with public Terraform users and members of Terraform Enterprise Organizations
- B . The ability to tag modules by version or release
- C . The ability to restrict modules to members of Terraform Cloud or Enterprise organizations
- D . The ability to share modules publicly with any user of Terraform
C
Explanation:
Terraform Cloud’s private registry works similarly to the public Terraform Registry and helps you share Terraform providers and Terraform modules across your organization. It includes support for versioning and a searchable list of available providers and modules.
You need to constrain the GitHub provider to version 2.1 or greater.
Which of the following should you put into the Terraform 0.12 configuration’s provider block?
- A . version >= 2.1
- B . version ~> 2.1
- C . version = “<= 2.1”
- D . version = “>= 2.1”
D
Explanation:
version = ">= 1.2.0, < 2.0.0"
A version constraint is a string literal containing one or more conditions, which are separated by commas.
Each condition consists of an operator and a version number.
Version numbers should be a series of numbers separated by periods (like 1.2.0), optionally with a suffix to indicate a beta release.
The following operators are valid:
= (or no operator): Allows only one exact version number. Cannot be combined with other conditions.
!=: Excludes an exact version number.
>, >=, <, <=: Comparisons against a specified version, allowing versions for which the comparison is true. "Greater-than" requests newer versions, and "less-than" requests older versions.
~>: Allows only the rightmost version component to increment. For example, to allow new patch releases within a specific minor release, use the full version number: ~> 1.0.4 will allow installation of 1.0.5 and 1.0.10 but not 1.1.0. This is usually called the pessimistic constraint operator.
https://www.terraform.io/language/expressions/version-constraints
CORRECT TEXT
FILL BLANK
You need to specify a dependency manually.
What resource meta-parameter can you use to make sure Terraform respects the dependency?
Type your answer in the field provided. The text field is not case-sensitive and all variations of the correct answer are accepted.