Fn::Base64Encode returns the Base64-encoded result of a string.
Note
Per the MIME standard, Base64-encoded output contains a line break after every 76 characters. Fn::Base64Encode also appends a trailing line break even if the input is shorter than 76 characters. Use Fn::Replace to remove the trailing line break.
The following example uses Fn::Replace to remove the trailing line break:
Fn::Replace:
- "\n": ''
- Fn::Base64Encode: string_to_encode
Declaration
-
JSON
{"Fn::Base64Encode": "stringToEncode"} -
YAML
-
Syntax for the full function name:
Fn::Base64Encode: stringToEncode -
Syntax for the short form:
!Base64Encode stringToEncode
-
Parameters
stringToEncode: the string that you want to encode in Base64.
Return value
The Base64-encoded result of the string.
Examples
!Base64Encode ALIYUN ROS{ "Fn::Base64Encode" : "ALIYUN ROS" }In this example, QUxJWVVOIFJPUw== is returned.