By default all the variables gets type as string which is not suitable for other type. The default type is any in terraform. It will be better to change file_handle.write(' type = string\n') to type = any in write_file function . End user can change later if needed and it wont throw error even if they did not for any other type variable.