How does Terraform convert between types automatically?
AdvancedConceptVariables, Locals, Outputs and Types
Answer
Primitive conversions are implicit (number to string and back, bool to string). Collections convert if element types convert, so a list of numbers can be passed where list(string) is expected. Tuples and objects convert to lists and maps when elements share a type. Use explicit functions (tostring, tonumber, tolist, toset, tomap) to make intent clear.
More on Variables, Locals, Outputs and Types
How do you declare an input variable?BeginnerIn what order does Terraform load variable values?BeginnerHow do you define an output and what is it for?BeginnerWhat is the difference between locals and variables?BeginnerWhat are the primitive types in Terraform?BeginnerHow do list, set and map differ?Intermediate