Retrieving a template - Amazon CloudFormation
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

Retrieving a template

Amazon CloudFormation stores the template you use to create your stack as part of the stack. To retrieve the template from CloudFormation use the aws cloudformation get-template command.


The aws cloudformation get-template command returns the deleted stacks templates for up to 90 days after the stack has been deleted.

The following example shows the template for the myteststack stack.

PROMPT> aws cloudformation get-template --stack-name myteststack { "TemplateBody": { "AWSTemplateFormatVersion": "2010-09-09", "Outputs": { "BucketName": { "Description": "Name of S3 bucket to hold website content", "Value": { "Ref": "S3Bucket" } } }, "Description": "Amazon CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the Amazon resources used if you create a stack from this template.", "Resources": { "S3Bucket": { "Type": "AWS::S3::Bucket", "Properties": { "AccessControl": "PublicRead" } } } } }

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