A team is using a module from the public Terraform Registry. They want to ensure that the module is pinned to a specific version to avoid unexpected changes. Which approach should they use?
Trap 1: Use 'required_providers' block in the root module to lock the…
required_providers is for provider versions, not module versions.
Trap 2: Add a 'version' argument inside the module block.
The version is specified in the source, not as a separate argument of the module block.
Trap 3: Store the module locally in a vendor directory and reference it by…
While possible, it's not the standard approach for version pinning from the registry.
- A
Use 'required_providers' block in the root module to lock the module version.
Why wrong: required_providers is for provider versions, not module versions.
- B
Add a 'version' argument inside the module block.
Why wrong: The version is specified in the source, not as a separate argument of the module block.
- C
Set 'version' in the module's source attribute, e.g., source = "terraform-aws-modules/vpc/aws" with version = "3.2.0".
Correct. The version constraint is specified as an argument in the module block alongside the source.
- D
Store the module locally in a vendor directory and reference it by path.
Why wrong: While possible, it's not the standard approach for version pinning from the registry.