Terraform-Associate-004 practice question 30 of 35

Which of the following is not a valid Terraform variable type?

Full set: 360 questions
Answer options
A: list
B: array Correct answer
C: nap Correct answer
D: string
Correct Answer:
B. array; C. nap
Explanation

The Terraform language (HCL) has a defined set of type constructors for declaring input variables. These include primitive types (string, number, bool) and complex types (list, map, set, object, tuple). The keyword array is not a valid type constructor in Terraform; the concept of an array is implemented using the list or tuple types. Similarly, nap is not a valid Terraform type keyword; it is most likely a typographical error for the valid type map.

Why Incorrect

A. list: This is incorrect because list is a valid collection type in Terraform, used to define a sequence of values of the same type.
D. string: This is incorrect because string is a valid primitive type in Terraform, used to represent a sequence of Unicode characters.

References

1. HashiCorp Terraform Documentation, Types and Values. In the "Complex Types" section, the documentation explicitly lists list, map, and set as collection types. The term array is not used as a type keyword.

Reference Location: Under the "Complex Types" heading, the documentation states: "Terraform has a number of complex types... The collection types are: list(...), map(...), set(...)."

2. HashiCorp Terraform Documentation, Input Variables - Type Constraints. This page provides examples of valid type constraints for variables.

Reference Location: The examples in this section demonstrate the use of string, list(string), and map(string), confirming their validity. The keywords array and nap are not shown or mentioned as valid types.

Scroll to Top