nerdexam
HashiCorp

TA-002-P · Question #39

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

The correct answer is B. default. No arguments are required in a Terraform variable declaration. A minimal valid variable block is simply 'variable "name" {}'. The 'type', 'default', and 'description' arguments are all optional. Omitting 'default' makes the variable mandatory at plan/apply time - Terraform will p

Read, generate, and modify configuration

Question

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

Options

  • Atype
  • Bdefault
  • Cdescription
  • DAll of the above
  • ENone of the above

How the community answered

(34 responses)
  • A
    6% (2)
  • B
    91% (31)
  • D
    3% (1)

Explanation

No arguments are required in a Terraform variable declaration. A minimal valid variable block is simply 'variable "name" {}'. The 'type', 'default', and 'description' arguments are all optional. Omitting 'default' makes the variable mandatory at plan/apply time - Terraform will prompt for a value or error if none is supplied - but the declaration itself is still valid. The provided answer key lists B (default), which is incorrect. The correct answer is E (None of the above).

Topics

#Terraform variables#Configuration syntax#Variable arguments

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice