0
0
Terraformcloud~20 mins

Tuple type definition in Terraform - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Tuple Type Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Tuple Type Definition in Terraform

Which of the following Terraform type definitions correctly defines a tuple with a string, a number, and a boolean in that order?

Atuple([bool, string, number])
Btuple([string, bool, number])
Ctuple([number, string, bool])
Dtuple([string, number, bool])
Attempts:
2 left
💡 Hint

Remember that tuple types require the exact order of types as elements.

Configuration
intermediate
2:00remaining
Tuple Type Validation in Terraform Variable

Given this Terraform variable declaration, which option correctly assigns a valid value to it?

variable "example" {
  type = tuple([string, number, bool])
}
A["hello", 42, true]
B[true, 42, "hello"]
C["hello", true, 42]
D[42, "hello", true]
Attempts:
2 left
💡 Hint

Match the order of types: string, number, bool.

Architecture
advanced
2:30remaining
Using Tuple Types for Module Inputs

You want to pass a tuple of a string and a number to a Terraform module input. Which type definition and input value pair is correct?

Atype = tuple([string, number]) with value [3, "app"]
Btype = tuple([number, string]) with value ["app", 3]
Ctype = tuple([string, number]) with value ["app", 3]
Dtype = tuple([bool, string]) with value [true, "app"]
Attempts:
2 left
💡 Hint

Check both the type order and the value order.

security
advanced
2:00remaining
Security Implications of Tuple Types in Terraform

Which statement about using tuple types for sensitive data in Terraform is true?

ATuple types can mark individual elements as sensitive to prevent exposure.
BTerraform does not support marking tuple elements as sensitive; the whole tuple must be sensitive.
CTuple types automatically encrypt sensitive elements at rest.
DUsing tuple types for sensitive data disables Terraform state encryption.
Attempts:
2 left
💡 Hint

Consider how Terraform handles sensitivity at the type level.

service_behavior
expert
3:00remaining
Behavior of Tuple Type with Optional Elements in Terraform 1.5+

In Terraform 1.5+, you define a tuple type with an optional third element: tuple([string, number, optional(bool)]). What happens if you assign the value ["test", 10] to this variable?

AThe assignment is valid; the optional bool element can be omitted.
BThe assignment causes a type error because the tuple length is less than 3.
CTerraform treats the missing bool as false automatically.
DTerraform fills the missing bool with null and raises a warning.
Attempts:
2 left
💡 Hint

Think about how optional elements in tuple types work in Terraform 1.5 and later.