TA-002-P · Question #253
Which one is the right way to import a local module names consul?
The correct answer is B. module "consul" { source = "./consul"} C. module "consul" { source = "../consul"}. Local modules must be referenced using relative file paths that start with ./ (same directory) or ../ (parent directory). Option B (./consul) sources the module from a subdirectory called consul in the current directory. Option C (../consul) sources it from a sibling directory…
Question
Which one is the right way to import a local module names consul?
Options
- Amodule "consul" { source = "consul"}
- Bmodule "consul" { source = "./consul"}
- Cmodule "consul" { source = "../consul"}
- Dmodule "consul" { source = "module/consul"}
How the community answered
(32 responses)- A16% (5)
- B75% (24)
- D9% (3)
Explanation
Local modules must be referenced using relative file paths that start with ./ (same directory) or ../ (parent directory). Option B (./consul) sources the module from a subdirectory called consul in the current directory. Option C (../consul) sources it from a sibling directory one level up. Option A (consul with no path prefix) would be interpreted as a Terraform Registry module, not a local path. Option D (module/consul) is also not a valid local path format - local paths must start with ./ or ../.
Topics
Community Discussion
No community discussion yet for this question.