HashiCorp certification · Exam Terraform-Associate-003

Terraform-Associate-003 Mock Exam Page 4

HashiCorp Certified: Terraform Associate (003) (HCTA0-003)

Free Terraform-Associate-003 mock exam questions 31–40, each with the answer and an explanation.

20 questions · 33 minutes · free, no sign-up

Free Terraform-Associate-003 questions

31–40 of 58 free
Question 31 Choose 1
Which is the best way to specify a tag of v1.0.0 when referencing a module stored in Git (for example.
Git::https://example.com/vpc.git)?
Show answerHide answer

Correct answer: A Append pref=v1.0.0 argument to the source path

Explanation

Explanation: The best way to specify a tag of v1.0.0 when referencing a module stored in Git is to append ?ref=v1.0.0 argument to the source path. This tells Terraform to use a specific Git reference, such as a branch, tag, or commit, when fetching the module source code. For example, source = "git::https://example.com/vpc.git?ref=v1.0.0". This ensures that the module version is consistent and reproducible across different environments. References = [Module Sources], [Module Versions]
Question 32 Choose 1
Variables declared within a module are accessible outside of the module.
Show answerHide answer

Correct answer: B False

Question 33 Choose 1
The public Terraform Module Registry is free to use.
Show answerHide answer

Correct answer: A True

Explanation

Explanation: The public Terraform Module Registry is free to use, as it is a public service that hosts thousands of self-contained packages called modules that are used to provision infrastructure. You can browse, use, and publish modules to the registry without any cost.
Question 34 Choose 1
Define the purpose of state in Terraform.
Show answerHide answer

Correct answer: A State maps real world resources to your configuration and keeps track of metadata

Explanation

Explanation: The purpose of state in Terraform is to keep track of the real-world resources managed by Terraform, mapping them to the configuration. The state file contains metadata about these resources, such as resource IDs and other important attributes, which Terraform uses to plan and manage infrastructure changes. The state enables Terraform to know what resources are managed by which configurations and helps in maintaining the desired state of the infrastructure.References = This role of state in Terraform is outlined in Terraform's official documentation, emphasizing its function in mapping configuration to real-world resources and storing vital metadata .
Question 35 Choose 1
Which of the following should you put into the required_providers block?
Show answerHide answer

Correct answer: B version = “>= 3.1”

Explanation

Explanation: The required_providers block is used to specify the provider versions that the configuration can work with. The version argument accepts a version constraint string, which must be enclosed in double quotes. The version constraint string can use operators such as >=, ~>, =, etc. to specify the minimum, maximum, or exact version of the provider. For example, version = ">= 3.1" means that the configuration can work with any provider version that is 3.1 or higher. References = [Provider Requirements] and [Version Constraints]
Question 36 Choose 3
Which are forbidden actions when the terraform state file is locked? Choose three correct answers.
Show answerHide answer

Correct answer: B, C, F Terraform destroyTerraform validateTerraform apply

Explanation

Explanation: The terraform state file is locked when a Terraform operation that could write state is in progress. This prevents concurrent state operations that could corrupt the state. The forbidden actions when the state file is locked are those that could write state, such as terraform apply, terraform destroy, terraform refresh, terraform taint, terraform untaint, terraform import, and terraform state *. The terraform validate command is also forbidden, because it requires an initialized working directory with the state file. The allowed actions when the state file is locked are those that only read state, such as terraform plan, terraform show, terraform output, and terraform console. References = [State Locking] and [Command: validate]
Question 37 Choose 1
Which type of block fetches or computes information for use elsewhere in a Terraform configuration?
Show answerHide answer

Correct answer: A data

Explanation

Explanation: In Terraform, a data block is used to fetch or compute information from external sources for use elsewhere in the Terraform configuration. Unlike resource blocks that manage infrastructure, data blocks gather information without directly managing any resources. This can include querying for data from cloud providers, external APIs, or other Terraform states.References = This definition and usage of data blocks are covered in Terraform's official documentation, highlighting their role in fetching external information to inform Terraform configurations.
Question 38 Choose 2
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.
Show answerHide answer

Correct answer: C, D Run terraform destroy and it will first output all the resource that will be deleted before prompting for approvalRun terraform plan .destory

Explanation

Explanation: To see all the resources that Terraform will delete, you can use either of these two commands:
terraform destroy will show the plan of destruction and ask for your confirmation before proceeding. You can cancel the command if you do not want to destroy the resources.
terraform plan -destroy will show the plan of destruction without asking for confirmation. You can use this command to review the changes before running terraform destroy. References = : Destroy Infrastructure : Plan Command: Options
Question 39 Choose 1
Select the command that doesn’t cause Terraform to refresh its state.
Show answerHide answer

Correct answer: D Terraform state list

Explanation

Explanation: This is the command that does not cause Terraform to refresh its state, as it only lists the resources that are currently managed by Terraform in the state file. The other commands will refresh the state file before performing their operations, unless you use the - refresh=false flag.
Question 40 Choose 1
You add a new provider to your configuration and immediately run terraform apply in the CD using the local backend. Why does the apply fail?
Show answerHide answer

Correct answer: C Terraform needs to install the necessary plugins first

Explanation

Explanation: The reason why the apply fails after adding a new provider to the configuration and immediately running terraform apply in the CD using the local backend is because Terraform needs to install the necessary plugins first. Terraform providers are plugins that Terraform uses to interact with various cloud services and other APIs. Each provider has a source address that determines where to download it from. When Terraform encounters a new provider in the configuration, it needs to run terraform init first to install the provider plugins in a local directory. Without the plugins, Terraform cannot communicate with the provider and perform the desired actions. References = [Provider Requirements], [Provider Installation]
Full mock exam

Sit the Terraform-Associate-003 exam before exam day

Full-length mocks with the same number of questions and the same time limit as the real Terraform-Associate-003 exam. Every attempt draws a new set of questions from the full bank, so you can keep going until you pass comfortably.

Get full Terraform-Associate-003 mock exam
  • 65questions per mock
  • 105 mintime limit
  • 194questions in the bank
  • Newmock on every attempt