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: BE

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

17 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 17, 2022

it is not mandatory tough! E is correct

Shane_C
Jul 4, 2023

He selected E as his answer

gcpzOption: E
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.

AzRNoobOption: E
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.

vikramvlrOption: E
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

Power123Option: E
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_COption: E
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 }

Tyler2023Option: E
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" { }

Molly1994Option: E
Jun 5, 2024

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