Which of the following statements about local modules is incorrect?
Which of the following statements about local modules is incorrect?
Local modules are sourced from a directory on disk and are used to organize and reuse Terraform code within a project. However, they do not support versions. This means changes to a local module will affect all resources using that module, as there is no versioning mechanism for local modules within Terraform.
Why not A? Are local modules cached or not?
Answer is C. In particular, modules sourced from local file paths do not support version; since they're loaded from the same source repository, they always share the same version as their caller. Reference: https://www.terraform.io/language/modules/syntax
The correct answer is C. "Local modules support versions" is incorrect. A. This statement is incorrect. Local modules are cached by the terraform init command. When you run terraform init, Terraform downloads and installs the modules specified in the configuration, including local modules, and caches them in the .terraform directory. B. This statement is correct. Local modules are sourced from a directory on disk. You can specify the path to the directory containing your local module in your Terraform configuration. C. This statement is incorrect. Local modules do not support versions in the same way remote modules hosted on version control systems (e.g., Git) do. Local modules are typically referenced by a relative or absolute path, and there is no versioning mechanism built into Terraform for local modules. D. This cannot be the correct answer because Statement B is correct. E. This cannot be the correct answer because Statement C is incorrect. So, the correct answer is C.
Version constraints are supported only for modules installed from a module registry, such as the public Terraform Registry or Terraform Cloud's private module registry. Other module sources can provide their own versioning mechanisms within the source string itself, or might not support versions at all. In particular, modules sourced from local file paths do not support version; since they're loaded from the same source repository, they always share the same version as their caller.
https://www.terraform.io/language/modules/syntax
C. Local modules support versions. Local modules are sourced from a directory on disk and are typically used to organize and reuse Terraform code within a project. However, local modules do not support versions. This means that if you make changes to a local module, those changes will be reflected in all resources that use that module, regardless of when those resources were created.