How do you specify version 1.0.0 for a module stored on the public Terraform Module Registry within a module block?

Prepare for the HashiCorp Terraform Associate Exam with quizzes, flashcards, and multiple-choice questions. Each question includes hints and explanations. Boost your confidence and ace your exam!

Multiple Choice

How do you specify version 1.0.0 for a module stored on the public Terraform Module Registry within a module block?

Explanation:
Pinning a specific module version from the public registry is done by adding a version argument inside the module block. This tells Terraform to fetch exactly that version and use it for planning and applying, ensuring reproducible infrastructure. For example: module "my_module" { source = "registry.terraform.io/hashicorp/example" version = "1.0.0" } If you omit the version, Terraform will pull the latest available release (subject to any other constraints), so you wouldn’t be guaranteed to get 1.0.0. The other approaches—using a query parameter on the source URL or assuming a default version—aren’t how the registry versioning works, and they won’t reliably lock you to 1.0.0.

Pinning a specific module version from the public registry is done by adding a version argument inside the module block. This tells Terraform to fetch exactly that version and use it for planning and applying, ensuring reproducible infrastructure.

For example:

module "my_module" {

source = "registry.terraform.io/hashicorp/example"

version = "1.0.0"

}

If you omit the version, Terraform will pull the latest available release (subject to any other constraints), so you wouldn’t be guaranteed to get 1.0.0. The other approaches—using a query parameter on the source URL or assuming a default version—aren’t how the registry versioning works, and they won’t reliably lock you to 1.0.0.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy