HashiCorp Certified: Terraform Associate (003) (HCTA0-003) Questions and Answers
Question 9
Which of the following should you add in the required_providers block to define a provider version constraint?
Options:
A.
version
B.
version = "3.1"
C.
version: 3.1
D.
version - 3.1
Answer:
B
Explanation:
Detailed Explanation:
Rationale for Correct Answer (B):Provider version constraints in Terraform are specified using the version argument in the required_providers block, e.g.:
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "3.1"
}
}
}
This ensures Terraform always uses a specific provider version (or constraint expression).
Analysis of Incorrect Options:
A. version: Incomplete, no value specified.
C. version: 3.1: Incorrect syntax, Terraform uses = not :.
D. version - 3.1: Incorrect syntax, - is invalid here.
Key Concept:Defining provider version constraints ensures consistent provider behavior across environments and avoids breaking changes.
How can terraform plan aid in the development process?
Options:
A.
Initializes your working directory containing your Terraform configuration files
B.
Validates your expectations against the execution plan without permanently modifying state
C.
Formats your Terraform configuration files
D.
Reconciles Terraform's state against deployed resources and permanently modifies state using the current status of deployed resources
Answer:
B
Explanation:
The terraform plan command is used to create an execution plan. It allows you to see what actions Terraform will take to reach the desired state defined in your configuration files. It evaluates the current state and configuration, showing a detailed outline of the resources that will be created, updated, or destroyed. This is a critical step in the development process as it helps you verify that the changes you are about to apply will perform as expected, without actually modifying any state or infrastructure.
Provisioning infrastructure in multiple cloud providers.
B.
Managing actions to take based on resource differences.
C.
Managing resources and data sources based on an API.
D.
Understanding API interactions with a hosted service.
Answer:
A
Explanation:
Detailed Explanation:
Rationale for Correct Answer (A):Providers only interact with one specific platform or API. Terraform itself can work with multiple providers in one configuration, but a single provider is not responsible for provisioning across multiple cloud providers.
Analysis of Incorrect Options:
B. Managing actions to take based on resource differences: This is a provider responsibility (through the resource schema).
C. Managing resources and data sources based on an API: Correct — providers define resources/data sources and map them to API calls.
D. Understanding API interactions with a hosted service: Correct — providers encapsulate API logic to allow Terraform to manage resources.
Key Concept:Providers are API adapters. They handle CRUD operations for resources in their own ecosystem but do not span across multiple cloud platforms.
Rationale for Correct Answer (False):Any user with access to the saved plan file (terraform plan -out=planfile) can run terraform apply planfile. Terraform does not enforce user-specific restrictions.
Analysis of Incorrect Option:
True: Incorrect — Terraform doesn’t tie plan files to individual users.
Key Concept:Plan files ensure predictability but are not bound to the identity of the user.
[Reference:Terraform Exam Objective – Understand Terraform Basics and CLI., ]