[英]How to transform a Serverless Application Model (SAM) template to Cloudformation?
From this answer I understand that SAM is a transform of Cloudformation.从这个答案中,我了解到 SAM 是 Cloudformation 的一种转换。
Is there a way to get the transformed Cloudformation template from a SAM template via the console, CLI, or another way?有没有办法通过控制台、CLI 或其他方式从 SAM 模板中获取转换后的 Cloudformation 模板?
For SAM projects already deployed, you should find the native CloudFormation template, post transformation, in the CloudFormation console.对于已部署的 SAM 项目,您应该在 CloudFormation 控制台中找到原生 CloudFormation 模板(转换后)。 Select your stack, then open the
Template
tab. Select 您的堆栈,然后打开
Template
选项卡。 You can also retrieve this via the awscli using aws cloudformation get-template
.您还可以使用
aws cloudformation get-template
通过 awscli 检索它。
You can also use the SAM cli, for example:您还可以使用 SAM cli,例如:
sam package \
--output-template-file output.yaml \
--s3-bucket mybucketname
I'm guessing you want to convert packaged SAM Template to a vanilla Cloudformation template.我猜您想将打包的 SAM 模板转换为普通的 Cloudformation 模板。
You can achieve this with the following easy steps:您可以通过以下简单步骤实现此目的:
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
Now you have a packaged vanilla CloudFormation template at output_file.json现在您在 output_file.json 处有一个打包的 vanilla CloudFormation 模板
More on this at https://github.com/awslabs/serverless-application-model/blob/develop/bin/sam-translate.py更多信息请访问https://github.com/awslabs/serverless-application-model/blob/develop/bin/sam-translate.py
There is a feature request for this.对此有一个功能请求。 Devs mentions a work-around using
sam validate --debug
.开发人员提到了使用
sam validate --debug
的解决方法。 It will show the transformed template, but also some other debugging info.它将显示转换后的模板,以及其他一些调试信息。
The solutions by Akshay and Jarmod seem to require having already deployed your code or full application, while this method works completely local. Akshay 和 Jarmod 的解决方案似乎需要已经部署您的代码或完整的应用程序,而这种方法完全在本地工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.