My input.tfvars file has the values for map variable named project as below:
project = {
name = "sampleproject"
team = "Code"
}
The definition for the same variable project for default values in variables.tf file is below:
variable "project"{
type = map(string)
default ={
name = "defaultproject"
team = "defaultteam"
}
}
Is the syntax for defining default variables is correct? or does the key also needs to be provided in quotes as below:
variable "project"{
type = map(string)
default ={
"name" = "defaultproject"
"team" = "defaultteam"
}
}
Google search provided answers with both of the above options for defining default variables for a map, hence I am asking here for clarification.
Keys in HCL2 Maps and Objects must be strings, and therefore any key is implicitly cast to String, and therefore does not need the explicit syntax for casting/constructing as a string i.e. ""
.
Note the documentation confirms keys must be String type.