In Terraform, variable names must be quoted strings. The type attribute expects a type identifier without quotes. The default value for a string must be quoted. Option B follows all these rules correctly.
availability_zones as a list of strings with two default values?Option A correctly uses list(string) as the type and provides a list of quoted strings as the default value. Variable names must be quoted strings. Option A misses the type parameter for list elements and lacks quotes around values. Option A misses quotes around the variable name. Option A has an invalid default value format.
Option C correctly declares a variable named "tags" with type map(string) and a default map with quoted string values. Option C misses the type parameter for map elements. Option C misses quotes around the variable name and values. Option C uses square brackets which is invalid for maps.
Option A correctly sets sensitive = true as a boolean without quotes. Options B, C, and D use invalid boolean representations causing syntax errors.
variable "instance_count" { type = number default = 3 }What will be the value of
instance_count if the module is called without specifying this variable?When a variable has a default value, Terraform uses that value if no override is provided. So instance_count will be 3. It will not be 0 or null, and no error occurs.