Which Terraform variable declaration correctly restricts the variable to accept only a list of strings?
Think about the data structure that holds multiple string values in order.
The list(string) type constraint ensures the variable only accepts a list where each item is a string. Other options either expect different data types or allow any type.
Which variable declaration will cause a Terraform configuration error due to an invalid type constraint?
Check the syntax for declaring a list of objects in Terraform.
The correct syntax for a list of objects is list(object) with parentheses, not square brackets. Option C uses square brackets which is invalid.
You want to define a Terraform variable that accepts a map where each key is a string and each value is an object with two attributes: id (string) and enabled (bool). Which type constraint is correct?
Think about the data structure: a map with string keys and object values.
Option B correctly defines a map with string keys and object values having the specified attributes. Option B uses a list instead of a map. Option B uses tuple which does not name attributes. Option B defines a single object, not a map.
Which Terraform variable type constraint best prevents users from passing sensitive data as a plain string by enforcing a map with specific keys?
Consider how to enforce structure and keys for sensitive data.
Using an object type with named attributes enforces that the variable must include both username and password keys as strings, preventing arbitrary or insecure input formats.
Given the variable declaration variable "ports" { type = list(number) }, what will happen if the user provides ["80", "443"] as input during terraform plan?
Think about how Terraform enforces variable types strictly during planning.
Terraform enforces type constraints strictly. Providing strings where numbers are expected causes a type mismatch error during plan, preventing deployment.