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 questions
Answer options
A: source - "github.com/hashicorp/examplePref-ul.0.8M
B: source = "./module?version=vl.6.0" Correct answer
C: source - "hashicorp/consul/aws"
D: source - "./module"
Correct Answer:
B. source = "./module?version=vl.6.0"
Explanation

The 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.

Why Incorrect

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.

References

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)

Scroll to Top