nerdexam
HashiCorp

TA-002-P · Question #277

Which of the following value will be accepted for my_var? 1. variable "my_var" 2. { 3. type = string 4. }

The correct answer is C. Both A and B. The Terraform language will automatically convert number and bool values to string values when needed, and vice-versa as long as the string contains a valid representation of a number or true converts to "true", and vice-versa false converts to "false", and vice-versa * 15…

Read, generate, and modify configuration

Question

Which of the following value will be accepted for my_var? 1. variable "my_var" 2. { 3. type = string 4. }

Options

  • A15
  • B"15"
  • CBoth A and B
  • DNone of the above

How the community answered

(52 responses)
  • A
    2% (1)
  • B
    4% (2)
  • C
    92% (48)
  • D
    2% (1)

Explanation

The Terraform language will automatically convert number and bool values to string values when needed, and vice-versa as long as the string contains a valid representation of a number or * true converts to "true", and vice-versa * false converts to "false", and vice-versa * 15 converts to "15", and vice-versa Where possible, Terraform automatically converts values from one type to another in order to produce the expected type. If this isn't possible, Terraform will produce a type mismatch error and you must update the configuration with a more suitable expression.

Topics

#Terraform variables#Variable types#String type#Type coercion

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice