Complete the code to define a variable with a default value.
variable "region" { type = string default = "[1]" }
The default value for the variable region is set to us-west-2.
Complete the code to override the variable value using a CLI flag.
terraform apply -var='region=[1]'
The CLI flag -var='region=eu-central-1' overrides the default variable value.
Fix the error in the variable declaration to set a description.
variable "environment" { type = string description = [1] default = "dev" }
The description must be a quoted string explaining the variable purpose.
Fill both blanks to set a variable with a type and a default list value.
variable "availability_zones" { type = [1] default = [2] }
The variable type is a list of strings, and the default is a list of availability zones.
Fill all three blanks to demonstrate variable precedence: default, environment variable, and CLI override.
# Variable with default variable "instance_type" { type = string default = "t2.micro" } # Environment variable override example # export TF_VAR_instance_type=[1] # CLI override example terraform apply -var='instance_type=[2]' # Final value used is [3]
The default is t2.micro. The environment variable sets t2.small. The CLI override sets t2.medium. CLI override has highest precedence, so final value is t2.medium.