Base64

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.

The base64 method is the CloudFormation Fn::Base64 equivalent.

Example Snippet

resource("Instance", "AWS::EC2::Instance",
  InstanceType: "t3.micro",
  ImageId: "ami-0de53d8956e8dcf80",
  UserData: base64("#!/bin/bash\necho hi")
)

Example Output

Resources:
  Instance:
    Type: AWS::EC2::Instance
    Properties:
      InstanceType: t3.micro
      ImageId: ami-0de53d8956e8dcf80
      UserData:
        Fn::Base64: |-
          #!/bin/bash
          echo hi

Back to Intrinsic Functions List.