Question 1 · choose 1
A root module uses a registry module and wants patch and minor releases of major version 3 but never version 4. Which setting expresses this?
- Aversion = "~> 3.0" in the module block
- Bversion = "~> 3.0.0" in the module block
- Csource = "terraform-aws-modules/vpc/aws@3"
- DA required_providers entry for the module with version "~> 3.0"
Show the answer and why
Aversion = "~> 3.0" in the module block
Correct
Registry modules accept a version constraint; "~> 3.0" allows 3.x releases and excludes 4.0.
Bversion = "~> 3.0.0" in the module block
Incorrect
That allows only 3.0.x patch releases, not 3.1 and later.
Csource = "terraform-aws-modules/vpc/aws@3"
Incorrect
Terraform does not accept an @ version suffix in a source address.
DA required_providers entry for the module with version "~> 3.0"
Incorrect
required_providers is for providers, not modules.
Registry modules carry their own version argument with the usual constraint syntax.
HashiCorp documentation