【发布时间】:2020-07-17 23:33:58
【问题描述】:
来自this answer 我了解到SAM 是Cloudformation 的转换。
有没有办法通过控制台、CLI 或其他方式从 SAM 模板中获取转换后的 Cloudformation 模板?
【问题讨论】:
标签: amazon-web-services amazon-cloudformation aws-sam aws-sam-cli serverless-application-model
来自this answer 我了解到SAM 是Cloudformation 的转换。
有没有办法通过控制台、CLI 或其他方式从 SAM 模板中获取转换后的 Cloudformation 模板?
【问题讨论】:
标签: amazon-web-services amazon-cloudformation aws-sam aws-sam-cli serverless-application-model
对于已部署的 SAM 项目,您应该在 CloudFormation 控制台中找到原生 CloudFormation 模板(转换后)。选择您的堆栈,然后打开Template 选项卡。您也可以使用 aws cloudformation get-template 通过 awscli 检索它。
您也可以使用 SAM cli,例如:
sam package \
--output-template-file output.yaml \
--s3-bucket mybucketname
【讨论】:
我猜您想将打包的 SAM 模板转换为普通的 Cloudformation 模板。
您可以通过以下简单步骤实现此目的:
pip install aws-sam-translator docopt
wget https://raw.githubusercontent.com/awslabs/serverless-application- model/develop/bin/sam-translate.py`
python sam-translate.py --template-file=input_file.yml --output-template=output_file.json
现在您在 output_file.json 中拥有一个打包的原生 CloudFormation 模板
更多信息请访问https://github.com/awslabs/serverless-application-model/blob/develop/bin/sam-translate.py
【讨论】: