Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 39


Which argument(s) is (are) required when declaring a Terraform variable?

Show Answer
Correct Answer: E

When declaring a Terraform variable, no specific arguments like type, default, or description are required. You can declare a variable with just a name, and the other arguments are optional and meant to provide additional constraints or descriptions. Therefore, the correct option is 'None of the above.'

Discussion

30 comments
Sign in to comment
Egger1992Option: E
May 2, 2022

The type argument in a variable block allows you to restrict the type of value that will be accepted as the value for a variable. If no type constraint is set then a value of any type is accepted. Source: https://www.terraform.io/language/values/variables

AWS_PT
Nov 18, 2022

it is not mandatory tough! E is correct

Shane_C
Jul 4, 2023

He selected E as his answer

Shane_C
Jul 4, 2023

He selected E as his answer

gcpz
Apr 26, 2022

Correct is E Terraform CLI defines the following OPTIONAL arguments for variable declarations: default - A default value which then makes the variable optional. type - This argument specifies what value types are accepted for the variable. description - This specifies the input variable's documentation. validation - A block to define validation rules, usually in addition to type constraints. sensitive - Limits Terraform UI output when the variable is used in configuration. nullable - Specify if the variable can be null within the module.

esandips
Apr 29, 2022

Ans: E Terraform CLI defines the following optional arguments for variable declarations: default - A default value which then makes the variable optional. type - This argument specifies what value types are accepted for the variable. description - This specifies the input variable's documentation. validation - A block to define validation rules, usually in addition to type constraints. sensitive - Limits Terraform UI output when the variable is used in configuration.

AzureGurl
Jun 12, 2022

E is the correct option. You can define like this variable "application_name" { } and it works, in the tf plan.

tipzzzOption: A
Apr 24, 2022

A for sure

Atta33Option: E
Oct 27, 2022

answer is E tested in my lab

calebvar
Apr 25, 2022

Answer should be A

dumbu
May 7, 2022

E is correct answer.

318touring
May 8, 2022

E is the correct answer

ParthasarathiOption: E
May 13, 2022

Correct is E

AzRNoob
Apr 7, 2023

E is correct. It is possible to declare a variable without any of the given arguments (type, default, description). In fact, a variable declaration only requires a name and an optional type constraint. So the correct answer is E. None of the above.

EltoothOption: E
Jun 27, 2022

E is correct answer. https://www.terraform.io/language/values/variables#arguments

Tomcrui1234589
Aug 7, 2022

Correct Answer E. When a variable block is written like variable "foo" { } you get an interactive prompts for entering values for foo all arguments are optional

DataConsultantOption: E
Dec 2, 2022

"The type argument in a variable block allows you to restrict the type of value that will be accepted as the value for a variable. If no type constraint is set then a value of any type is accepted."

vikramvlr
Dec 13, 2022

Answer is E. we can declare the variable as variable "varname" {} type,default and description are optional..

sahara99Option: E
Feb 15, 2023

non of the options is mandatory - they are all optional

Power123
Mar 30, 2023

Answer is E. All are optional

campsOption: E
Mar 31, 2023

None of the above arguments are required when declaring a Terraform variable. However, at least one of the following arguments is required: type: Specifies the data type of the variable. Valid types include string, number, bool, list, map, and object. default: Specifies the default value of the variable. If no default value is specified, the variable is considered required and must be set by the user when running Terraform. description: Provides a description of the variable and its intended use. This is optional but recommended to make the purpose of the variable clear to users. In addition to these arguments, there are several other optional arguments that can be used when declaring a Terraform variable, including validation, sensitive, and allowed_values.

FaaizzOption: E
Apr 4, 2023

Definitely E

Ni33Option: E
May 8, 2023

E is the correct answer

vj_dhaksh
Jun 13, 2023

Arguments Terraform CLI defines the following optional arguments for variable declarations: default - A default value which then makes the variable optional. type - This argument specifies what value types are accepted for the variable. description - This specifies the input variable's documentation. validation - A block to define validation rules, usually in addition to type constraints. sensitive - Limits Terraform UI output when the variable is used in configuration. nullable - Specify if the variable can be null within the module.

Shane_C
Jul 4, 2023

E is correct

mirekbehanOption: E
Jul 13, 2023

Yes E is correct.

BereOption: E
Jul 29, 2023

When declaring a variable in Terraform, no arguments are required. However, there are optional arguments you can include for clarity and readability: description: This is a string that describes the purpose of the variable. default: This is the default value that Terraform will use if no other value is provided. type: This constrains the type of value the variable will accept, such as string, list, map, number, or bool. Here's an example of a variable declaration with no arguments: variable "example" { } And here's an example with all optional arguments included: variable "example" { description = "An example variable used for demonstration purposes" default = "Hello, World!" type = string }

Tyler2023
Oct 21, 2023

Correct, the answer is E https://developer.hashicorp.com/terraform/language/values/variables#disallowing-null-input-values

ghostGuiggsOption: E
Nov 2, 2023

E is the answer

samimshaikhOption: E
Dec 29, 2023

we can define variables without type, default, and description. default argument will require and value when terraform apply is executed. So in the context of this question is it required and answer is not variable "prefix" { } variable "location" { }

Molly1994
Jun 5, 2024

they are all optional arguments for variable declarations. so E is correct none of them are required

anand0310Option: E
Aug 31, 2024

E is correct

didistars13Option: D
Jan 15, 2025

Well, normally you can define all of them are required but only type is mandatory which means that you can define a variable with type only others are optional. But since question contains "required" and not a "mandatory" I choose D

Insanewhip
Feb 8, 2025

Type is not required, neither are the other options. "Required" and "mandatory" are the same thing. The correct answer is E.