AWS CloudFormation
User Guide (API Version 2010-05-15)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

Retrieving a Template

This section shows you how to retrieve a AWS CloudFormation template.

AWS CloudFormation stores the template you use to create your stack as part of the stack. You can download the template from AWS CloudFormation using the cfn-get-template command. Even if a stack has been deleted, you can download its template.

Note

The command returns the deleted stacks templates for up to 90 days after the stack has been deleted.

For example, suppose you have created a stack named MySQSTemplate which creates a simple SQS queue. The following shows what could be returned by cfn-get-template:

PROMPT> cfn-get-template MySQSTemplate

TEMPLATE "{
    "AWSTemplateFormatVersion" : "2010-09-09",
    "Resources" : {
        "MyInstance" : {
            "Type" : "AWS::EC2::Instance",
            "Properties" : {
                "UserData" : {
                    "Fn::Base64" : {
                      "Fn::Join" : [ "", [ "Queue=", { "Ref" : "MyQueue" }]]
                    }
                },
                "AvailabilityZone" : "us-east-1a",
                "ImageId" : "ami-20b65349"
            }
        },
        "MyQueue" : {
            "Type" : "AWS::SQS::Queue",
            "Properties" : {
            }
        }
    },
    "Outputs" : {
        "QueueName" : {
            "Value" : { "Ref" : "MyQueue" }
        }
    }
}
"

The output contains the entire template body, enclosed in quotation marks.