Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Terraform Associate All Questions

View all questions & answers for the Terraform Associate exam

Exam Terraform Associate topic 1 question 101 discussion

Actual exam question from HashiCorp's Terraform Associate
Question #: 101
Topic #: 1
[All Terraform Associate Questions]

If a module declares a variable with a default, that variable must also be defined within the module.

  • A. True
  • B. False
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
govs
Highly Voted 1 year, 7 months ago
Selected Answer: B
If a module declares a variable with a default value, it is not necessary to define the variable within the module calling the module. The module will automatically use the default value if a value is not explicitly assigned to the variable in the calling module
upvoted 10 times
...
Eltooth
Highly Voted 2 years, 4 months ago
Selected Answer: B
B is correct answer.
upvoted 7 times
...
Clapton79
Most Recent 1 year ago
This question does not make sense in its current form. (Very poor English, sorry) You declare the variable with variable "my_var" {type=string} and in there you may add a default: variable "my_var" { type=string default="a" } SETTING a variable in a statement calling a module that contains this variable is not compulsory. module "my_module" { source= "./this_module" my_var = "b" # <-- you can omit this in which case the value will be "a" }
upvoted 5 times
umavaja
11 months, 2 weeks ago
Agree, very poor English, same issue even for UDEMY courses as well Terraform documentation
upvoted 3 times
...
...
otakuinside
1 year, 1 month ago
The variable must be declared aswell, another thing is that you have to assign a value to it. But the declaration is mandatory. At least this is my understanding of what the question says.
upvoted 1 times
...
Alex1778
1 year, 7 months ago
B is correct answer.
upvoted 1 times
...
Power123
1 year, 7 months ago
Bis correct
upvoted 1 times
...
Nunyabiznes
1 year, 8 months ago
Selected Answer: B
False. If a module declares a variable with a default value, it does not necessarily need to be defined within the module. The default value will be used if the variable is not set in the calling module. For example, consider the following module: ``` variable "instance_type" { description = "The instance type to use" default = "t2.micro" } resource "aws_instance" "example" { ami = "ami-0c55b159cbfafe1f0" instance_type = var.instance_type } ```
upvoted 5 times
Nunyabiznes
1 year, 8 months ago
In this module, a variable called instance_type is declared with a default value of t2.micro. The default value will be used if the variable is not set in the calling module. If the calling module does not set the instance_type variable, the default value of t2.micro will be used. If the calling module does set the instance_type variable, the value from the calling module will be used instead of the default. It is important to note that if a variable is declared without a default value and is not set in the calling module, Terraform will prompt the user to enter a value for that variable.
upvoted 6 times
...
...
SilentMilli
1 year, 8 months ago
Selected Answer: B
A module can declare a variable with a default value without defining it within the module. This is because the variable can be used as-is with the default value, or it can be assigned a new value by code that imports the module.
upvoted 2 times
...
bukake
2 years, 3 months ago
Where are 102-103-104 Questions?
upvoted 4 times
kopper2019
2 years, 3 months ago
no idea, I am taking exam tomorrow
upvoted 2 times
hello2022
2 years, 2 months ago
How did you do? How relevant were these questions.
upvoted 1 times
...
...
...
gsx
2 years, 5 months ago
Selected Answer: B
when no value is passed, default value will be automatically be taken.
upvoted 4 times
...
Maaran07
2 years, 6 months ago
It is not mandatory to define inside module. default can be in module itself.
upvoted 1 times
...
traceme
2 years, 6 months ago
Why not A . When we define the variable as default , we need to pass tha value for the variables right
upvoted 2 times
habros
2 years, 5 months ago
It already had a variable. Worse case it knows where to get if it’s not manually defined
upvoted 1 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...