TERRAFORM-ASSOCIATE-003 practice question 24 of 30
[Interact with Terraform Modules] Which of the following is not a valid source path for specifying a module?
Full set: 226 questionsThe source argument for a module block does not support appending a version query string (?version=...) to a local file path. Local paths (./module) refer directly to a directory on the local filesystem, and Terraform uses the code present in that directory. Version constraints are handled differently: for modules from a registry, a separate version argument is used within the module block. For Git-based sources, a ref query parameter (e.g., ?ref=v1.6.0) can be used to specify a branch, tag, or commit hash, but the ?version= syntax is not used for local paths.
A. This is a valid format for sourcing a module directly from a public GitHub repository. Terraform recognizes github.com as a shorthand for a Git source.
C. This is the standard, valid address format for a module hosted on the public Terraform Registry, specified as //.
D. This is a valid way to reference a module using a relative local path. The ./ indicates that the module directory is in the same directory as the calling configuration.
1. HashiCorp Terraform Documentation
"Module Sources": This document details the various types of supported module sources.
Local Paths: The documentation shows examples like source = "./child-module". It makes no mention of versioning parameters being appended to the path string. (Reference: developer.hashicorp.com/terraform/language/modules/sources#local-paths)
Terraform Registry: This section explains the // format and explicitly states that versioning is handled by a separate version argument
not as part of the source string. (Reference: developer.hashicorp.com/terraform/language/modules/sources#terraform-registry)
GitHub: This section confirms that github.com/hashicorp/example is a valid source. It also clarifies that versioning is done via the ref argument in the query string (e.g.
?ref=v1.2.0)
not ?version=.... (Reference: developer.hashicorp.com/terraform/language/modules/sources#github)
Keep practicing
Take the free TERRAFORM-ASSOCIATE-003 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other TERRAFORM-ASSOCIATE-003 practice questions
- Question 1[Understand Terraform Basics and CLI] If you update the version constraint in your Terraf…
- Question 2[Navigate Terraform State and Backends] Terraform variable names are saved in the state f…
- Question 3[Understand Terraform Basics and CLI] You modified your Terraform configuration and run T…
- Question 4[Understand Terraform Basics and CLI] You must use different Terraform commands depending…
- Question 6[Understand Terraform Basics and CLI] terraform init creates an example main.tf file in t…
- Question 7[Understand Terraform Basics and CLI] terraform validate confirms that your infrastructur…
