What is the best way to specify a tag of v1.0.0 when referencing a module stored in Git (for example git::https://example.com/vpc.git)?

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

What is the best way to specify a tag of v1.0.0 when referencing a module stored in Git (for example git::https://example.com/vpc.git)?

Explanation:
When you reference a Git-based module, you pin the exact revision using a ref query parameter on the Git URL. Terraform’s git source can checkout a specific tag, branch, or commit by supplying ref. So to use v1.0.0, you append ?ref=v1.0.0 to the URL, for example: source = "git::https://example.com/vpc.git?ref=v1.0.0" This is necessary because the version attribute is for modules from the Terraform Registry, not for Git sources. GitHub’s tags don’t automatically fix the version in Terraform; you must specify the ref explicitly.

When you reference a Git-based module, you pin the exact revision using a ref query parameter on the Git URL. Terraform’s git source can checkout a specific tag, branch, or commit by supplying ref. So to use v1.0.0, you append ?ref=v1.0.0 to the URL, for example:

source = "git::https://example.com/vpc.git?ref=v1.0.0"

This is necessary because the version attribute is for modules from the Terraform Registry, not for Git sources. GitHub’s tags don’t automatically fix the version in Terraform; you must specify the ref explicitly.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy