Parameterize a string, possibly encoding it as Base64 afterwards

    Args:
        raw (`str` | `bytes`): String to be processed. Byte strings will be
            interpreted as UTF-8.
        b64 (`bool`): Whether to wrap the output in a Base64 CloudFormation
            call

    Returns:
        :class:`troposphere.AWSHelperFn`: output to be included in a
        CloudFormation template.

def parameterized_codec(raw, b64):
    """Parameterize a string, possibly encoding it as Base64 afterwards

    Args:
        raw (`str` | `bytes`): String to be processed. Byte strings will be
            interpreted as UTF-8.
        b64 (`bool`): Whether to wrap the output in a Base64 CloudFormation
            call

    Returns:
        :class:`troposphere.AWSHelperFn`: output to be included in a
        CloudFormation template.
    """

    if isinstance(raw, bytes):
        raw = raw.decode('utf-8')

    result = _parameterize_string(raw)

    # Note, since we want a raw JSON object (not a string) output in the
    # template, we wrap the result in GenericHelperFn (not needed if we're
    # using Base64)
    return Base64(result.data) if b64 else result