Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Fn::Base64

Focus mode
Fn::Base64 - AWS CloudFormation
Filter View

The intrinsic function Fn::Base64 returns the Base64 representation of the input string. This function is typically used to pass encoded data to Amazon EC2 instances by way of the UserData property.

Declaration

JSON

{ "Fn::Base64" : valueToEncode }

YAML

Syntax for the full function name:

Fn::Base64: valueToEncode

Syntax for the short form:

!Base64 valueToEncode
Note

If you use the short form and immediately include another function in the valueToEncode parameter, use the full function name for at least one of the functions. For example, the following syntax isn't valid:

!Base64 !Sub string !Base64 !Ref logical_ID

Instead, use the full function name for at least one of the functions, as shown in the following examples:

!Base64 "Fn::Sub": string Fn::Base64: !Sub string

Parameters

valueToEncode

The string value you want to convert to Base64.

Return value:

The original string, in Base64 representation.

Example

JSON

{ "Fn::Base64" : "AWS CloudFormation" }

YAML

Fn::Base64: AWS CloudFormation

Supported functions

You can use any function that returns a string inside the Fn::Base64 function.

See also

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.