i have a string the is formed from a number of variables which i use for many different things such as Tags and host names.

is there a way of creating a reusable string that i can just Ref though out the template?

any thoughts on this would be much appreciated. edit: An example would be passing in 2 parameters such as ProjectName and Environment joining them

"Fn::Join" : [ "-", [ {"Ref":"ProjectName"}, {"Ref":"Environment"} ] ]

and using the results in a number of places


Unfortunately my experiments are to agree with your conclusion Graeme. I have struggled with this for some time but not found a way of computing a String via Fn::Join and keeping it for later in the template.

Can I share with you a typical example?

As at 2014-09-18, the most sophisticated way of storing a string value for re-use in the Resources section would be via a (second-level) Mapping. Better still, I can pre-compute a Condition and determine whether to use the string or not. But unfortunately the storing of a string just does not work.

Here is an example stanza of such a Mapping …

    "LoadBalancerBucketMap": {
        "BucketName": {
            "string": {
                "Fn::Join": [
                            "Ref": "Environment"

And here is an access expression to it in a Resource

                "S3BucketName": {
                    "Fn::FindInMap": [

In this example, Environment is a literal string Parameter with a convenient default. So that is a very clear example of creating and re-using a string. But here is what the CloudFormation processor says …

Template validation error: Template format error: Every Mappings attribute must be a String or a List.

So I share your frustration that there does not seem to be a way in a template to provide the effect of a temporary string variable.

… So far as I can see. But the answer you originally received said the opposite of this (although without an example).

So if anyone does have an example workaround, then please could they share?

|improve this answer|||||

You can use params or mappings to store strings that you can use in your templates.

|improve this answer|||||
  • 1
    This only works for static strings. The OP specifically asked for computed strings, which doesn't seem to be possible at all. – Joe Apr 21 '16 at 20:31

unfortunately i have found that it not possible to do what i was trying to achieve. it doesn't help but there it is.

|improve this answer|||||

We actually make our CloudFormation stack name exactly {ProjectName}-{Environment} during aws cloudformation deploy. Have you considered this naming convention for your stack name?

Afterwards, you can just reference it as { "Fn:Sub": "${AWS::StackName}" }.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.