You are reading documents incorrectly. Although the documents say that you can use the function Ref, only in the second (optional) parameter (key-value map) can you do this.
Example provided in the documentation:
{"Fn::Sub": ["www.${Domain}", {"Domain": {"Ref": "RootDomainName"}}]}
However, if you need to substitute the first parameter, you must use dollar notation.
To achieve what you want, you must rewrite the code as follows:
{"Fn::Sub": "${UserDataParam}"}
Or in context:
"UserData": {"Fn::Base64": {"Fn::Sub": "${UserDataParam}"}}
source
share