convert Function
convert
converts a value or an expression to a given type.
Explicit type conversions are rarely necessary in HCL because it will convert types automatically where required. Use the explicit type conversion functions only to normalize types returned in outputs.
Only numbers and strings containing decimal representations of numbers can be converted to number. All other values will produce an error.
Only boolean values and the exact strings "true" and "false" can be converted to boolean. All other values will produce an error.
Only the primitive types (string, number, and bool) can be converted to string. All other values will produce an error.
convert(value, type_constraint)
Examples