The built-in function Fn::Base64Encode returns the Base64-encoded format of a string.
In the Multipurpose Internet Mail Extensions (MIME) standard, a Base64-encoded output usually contains a line break after every 76 characters to ensure that each line does not exceed 76 characters in length. Even if the string that you specify is less than 76 characters in length, the Fn::Base64Encode function automatically adds a line break at the end of the string. You can use the Fn::Replace function to remove the line break.
The following sample code provides an example on how to use Fn::Replace to remove the line break at the end of a string to be returned by the Fn::Base64Encode function:
Fn::Replace:
- "\n": ''
- Fn::Base64Encode: string_to_encodeDeclaration
JSON
{"Fn::Base64Encode": "stringToEncode"}YAML
Syntax for the full function name:
Fn::Base64Encode: stringToEncodeSyntax for the short form:
!Base64Encode stringToEncode
Parameters
stringToEncode: the string that you want to encode in Base64.
Return value
The Base64-encoded format of the string.
Examples
!Base64Encode ALIYUN ROS{ "Fn::Base64Encode" : "ALIYUN ROS" }In this example, QUxJWVVOIFJPUw== is returned.