in cloudformation is it possible to create a reusable string?

Solution 1:

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?

Solution 2:

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