擷取 CloudFormation 範本 AWS CLI - AWS CloudFormation

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

擷取 CloudFormation 範本 AWS CLI

CloudFormation 將您用來建立堆疊的範本儲存為堆疊的一部分。若要從中擷取範本 CloudFormation,請使用get-templateCLI指令。

get-template 命令會傳回自刪除起最長經過 90 天的已刪除堆疊範本。

下面的get-template命令顯示了myteststack堆棧的模板。

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": "AWS 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 AWS resources used if you create a stack from this template.", "Resources": { "S3Bucket": { "Type": "AWS::S3::Bucket", "Properties": { "AccessControl": "PublicRead" } } } } }

輸出包含整個範本本文,並括在引號中。