Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 40


When using a module block to reference a module stored on the public Terraform Module Registry such as:

How do you specify version 1.0.0?

Show Answer
Correct Answer: C

To specify version 1.0.0 of a module stored on the public Terraform Module Registry, you need to add the version attribute within the module block. This ensures that the desired module version is used and prevents unexpected updates. The correct syntax for specifying version 1.0.0 is as follows: module "consul" { source = "hashicorp/consul/aws" version = "1.0.0" }. This approach is recommended to maintain consistency and control over module versions.

Discussion

10 comments
Sign in to comment
amrith501Option: C
Dec 12, 2022

C correct answer Version When using modules installed from a module registry, we recommend explicitly constraining the acceptable version numbers to avoid unexpected or unwanted changes. Use the version argument in the module block to specify versions: module "consul" { source = "hashicorp/consul/aws" version = "0.0.5" servers = 3 }

foreverlearnerOption: C
Jan 5, 2024

Although please note that version is now deprecated in favour of the required_providers block https://developer.hashicorp.com/terraform/language/providers/configuration#version-deprecated

foreverlearner
Jan 5, 2024

Ok sorry my bad this is a module not a provider so that's not relevant (but still good to know though :) ) Answer is still C

elvancedonzyOption: C
Dec 1, 2022

C is correct https://www.terraform.io/language/modules/syntax

EltoothOption: C
Dec 27, 2022

C is correct answer. The version argument accepts a version constraint string. Terraform will use the newest installed version of the module that meets the constraint; if no acceptable versions are installed, it will download the newest version that meets the constraint. 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#version

aleksand41Option: C
Apr 6, 2023

C is correct

sahara99Option: C
Aug 15, 2023

example from HashiCorp: module "consul" { source = "hashicorp/consul/aws" version = "0.0.5" servers = 3 }

BereOption: C
Jan 29, 2024

Example: module "consul" { source = "hashicorp/consul/aws" version = "1.0.0" // other necessary arguments... }

Power123
Sep 30, 2023

C is correct

Ni33Option: C
Nov 1, 2023

C is the correct answer. It is used to lock down version of the modules in production grade infrastructure templates.

enookOption: C
Jul 3, 2024

CCCCCC