Fn::Sub with a Mapping
The following example uses a mapping to substitute the ${Domain} variable with the resulting value from the Ref function.
JSON
{ "Fn::Sub": [ "www.${Domain}", { "Domain": {"Ref" : "RootDomainName" }} ]}
YAML
Name: !Sub
- www.${Domain}
- { Domain: !Ref RootDomainName }
from https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html