【问题标题】:How to transform a Serverless Application Model (SAM) template to Cloudformation?如何将无服务器应用程序模型 (SAM) 模板转换为 Cloudformation?
【发布时间】: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


    【解决方案1】:

    对于已部署的 SAM 项目,您应该在 CloudFormation 控制台中找到原生 CloudFormation 模板(转换后)。选择您的堆栈,然后打开Template 选项卡。您也可以使用 aws cloudformation get-template 通过 awscli 检索它。

    您也可以使用 SAM cli,例如:

    sam package \
      --output-template-file output.yaml \
      --s3-bucket mybucketname
    

    【讨论】:

      【解决方案2】:

      我猜您想将打包的 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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-09-24
        • 2020-07-09
        • 2018-04-14
        • 2020-06-10
        • 2020-01-05
        • 2019-02-13
        • 2017-08-17
        • 2018-10-12
        相关资源
        最近更新 更多