code: def validate_variable_type(var_name, var_type, value):
      
  
      if isinstance(var_type, CFNType):
          value = CFNParameter(name=var_name, value=value)
      elif isinstance(var_type, TroposphereType):
          try:
              value = var_type.create(value)
          except Exception as exc:
              name = "{}.create".format(var_type.resource_name)
              raise ValidatorError(var_name, name, value, exc)
      else:
          if not isinstance(value, var_type):
              raise ValueError(
                  "Value for variable %s must be of type %s. Actual "
                  "type: %s." % (var_name, var_type, type(value))
              )
  
      return value
docs: Ensures the value is the correct variable type.
  
      Args:
          var_name (str): The name of the defined variable on a blueprint.
          var_type (type): The type that the value should be.
          value (obj): The object representing the value provided for the
              variable
  
      Returns:
          object: Returns the appropriate value object. If the original value
              was of CFNType, the returned value will be wrapped in CFNParameter.
  
      Raises:
          ValueError: If the `value` isn't of `var_type` and can't be cast as
              that type, this is raised.