Practice Free Terraform Associate 004 Exam Online Questions
Terraform variables and outputs that set the description argument will store that description in the state file.
- A . True
- B . False
B
Explanation:
The description argument for Terraform variables and outputs is purely for documentation purposes and isnotstored in the Terraform state file.
Terraform variables and outputs can have descriptions for readability and clarity in.tf files.
However, these descriptions are not retained in the Terraform state file.
The state file only stores actual values and references needed for resource management, not metadata such as descriptions.
Official Terraform Documentation
Reference: Terraform Variables – HashiCorp Documentation
Terraform Outputs – HashiCorp Documentation
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)
- A . Runterraform destroy. This will output all the resources that will be deleted before prompting for approval.
- B . Runterraform show -destroy.
- C . Runterraform state rm *.
A,B
Explanation:
Runningterraform destroywill show all resources that will be deleted before prompting for approval. You can also runterraform plan -destroyto simulate the destruction without actually applying it, which is useful for reviewing the planned changes.
Reference: Terraform Destroy
Which of the following statements about Terraform modules is not true?
- A . Modules can call other modules
- B . A module is a container for one or more resources
- C . Modules must be publicly accessible
- D . You can call the same module multiple times
C
Explanation:
This is not true, as modules can be either public or private, depending on your needs and preferences. You can use the Terraform Registry to publish and consume public modules, or use Terraform Cloud or Terraform Enterprise to host and manage private modules.
How does the Terraform cloud integration differ from other state backends such as S3, Consul,etc?
- A . It can execute Terraform runs on dedicated infrastructure in Terraform Cloud
- B . It doesn’t show the output of a terraform apply locally
- C . It is only arable lo paying customers
- D . All of the above
A
Explanation:
This is how the Terraform Cloud integration differs from other state backends such as S3, Consul, etc.,
as it allows you to perform remote operations on Terraform Cloud’s servers instead of your local machine. The other options are either incorrect or irrelevant.
terraform validate reports syntax check errors for which of the following?
- A . Code contains tabs for indentation instead of spaces
- B . There is a missing value for a variable
- C . The state file does not match the current infrastructure
- D . None of the above
D
Explanation:
The terraform validate command is used to check for syntax errors and internal consistency within
Terraform configurations, such as whether all required arguments are specified. It does not check for indentation styles, missing variable values (as variables might not be defined at validation time), or state file consistency with the current infrastructure. Therefore, none of the provided options are correct in the context of what terraform validate reports.
Reference = Terraform’s official documentation details the purpose and function of the terraform validate command, specifying that it focuses on syntaxand consistency checks within Terraform configurations themselves, not on external factors like the state file or infrastructure state. Direct references from the HashiCorp Terraform Associate (003) study materials to this specific detail were not found in the provided files.
Which of these commands makes your code more human readable?
- A . Terraform validate
- B . Terraform output
- C . Terraform show
- D . Terraform file
D
Explanation:
The command that makes your code more human readable is terraform fmt. This command is used to rewrite Terraform configuration files to a canonical format and style, following the Terraform language style conventions and other minor adjustments for readability. The command is optional, opinionated, and has no customization options, but it is recommended to ensure consistency of style across different Terraform codebases. Consistency can help your team understand the code more quickly and easily, making the use of terraform fmt very important. You can run this command on your configuration files before committing them to source control or as part of your CI/CD pipeline.
Reference =: Command: fmt: Using Terraform fmt Command to Format Your Terraform Code
Which task does terraform init not perform?
- A . Discovers all providers used in the configuration and downloads them.
- B . Validates that values are set for all required input variables.
- C . Connects to the configured backend.
- D . Discovers any remote modules and downloads them.
B
Explanation:
Rationale for Correct Answer
terraform init initializes the working directory: it sets up the backend, downloads providers, and installs modules. It does not validate that required input variables have values―that check occurs when running commands that evaluate the configuration (typically
plan/apply), and terraform validate checks configuration structure, not whether you supplied runtime variable values.
Analysis of Incorrect Options (Distractors):
A: Yes―init installs required providers.
C: Yes―init initializes and configures the backend.
D: Yes―init retrieves and installs modules referenced by module blocks. Key Concept: What terraform init does vs what happens at plan/apply time.
Reference: Terraform Objectives ― Understand Terraform Basics and CLI (init responsibilities and workflow).
How does Terraform determine dependencies between resources?
- A . Terraform requires resource dependencies to be defined as modules and sourced in order
- B . Terraform automatically builds a resource graph based on resources provisioners, special meta-
parameters, and the stale file (if present} - C . Terraform requires resources in a configuration to be listed m the order they will be created to determine dependencies
- D . Terraform requires all dependencies between resources to be specified using the depends_on parameter
B
Explanation:
This is how Terraform determines dependencies between resources, by using the references between them in the configuration files and other factors that affect the order of operations.
Which of the following should you put into the required_providers block?
- A . version >= 3.1
- B . version = “>= 3.1”
- C . version ~> 3.1
B
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.
Reference = [Provider Requirements] and [Version Constraints]
What does this code do?
terraform { required_providers { aws = ">= 3.0" }}
- A . Requires any version of the AWS provider > = 3.0 and <4.0
- B . Requires any version of the AWS provider >= 3.0
- C . Requires any version of the AWS provider > = 3.0 major release. like 4.1
- D . Requires any version of the AWS provider > 3.0
A
Explanation:
From the Terraform Provider Requirements:
">= 3.0" means any versiongreater than or equal to 3.0― including 4.x and beyond.
A (wrong): Would need >= 3.0, < 4.0
C/D (wrong): > excludes 3.0 ― not what’s written.
