【问题标题】:Get AWS cloudformation for an existing lambda获取现有 lambda 的 AWS cloudformation
【发布时间】:2019-01-13 08:28:24
【问题描述】:

有什么方法可以得到 lambdas 的 cloudformation 吗? 我知道您可以使用 CloudFormer 从现有 AWS 资源创建 AWS CloudFormation 模板。而且,在我提出这个问题时,cloudformer 处于 beta 模式(AWS CloudFormer 0.41 (Beta))。在关注documentation 时,我找不到为我的 lambda 创建 cloudformation 的方法

我在创建 cloudformation 时选择了所有内容,但是 模板不包含 lambda。

不支持还是我遗漏了什么? 如果不支持,这背后的原因是什么?

【问题讨论】:

  • 似乎没有办法,但是下面的链接对我有帮助。希望它对你也有用。 stackoverflow.com/questions/50906085/…
  • lambda clouformation 没有什么秘密。我可以在答案中分享我的 yaml 模板。
  • @Cleriston 谢谢,我正在寻找一种导出 cloudFormation 模板的方法。其他cmet中的链接演示了一种方式
  • 该示例有一个 AWS SAM 的配置,它是 CloudFormation 的差异。它有不同的代码管理程序。但是,如果它是您正在寻找的东西,我无话可说。干杯。

标签: amazon-web-services aws-lambda amazon-cloudformation


【解决方案1】:

如果您将 Lambda 代码保存到磁盘,您可以使用 Rubycfn 在 CloudFormation 中创建您的 Lambda 函数。

gem install rubycfn

将下面的文件保存到example.rb 并运行rubycfn example.rb 以生成CloudFormation。

def file_to_inline(filename)
  File.open(filename).read.split("\n")
end

resource :my_lambda_function,
         type: "AWS::Lambda::Function" do |r|
  r.property(:code) do
    {
      "ZipFile": file_to_inline("/path/to/lambda.py").fnjoin("\n")
    }
  end
  r.property(:role) { :your_lambda_role.ref(:arn) }
  r.property(:handler) { "index.lambda_handler" }
  r.property(:runtime) { "some_runtime" }
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-07-29
    • 2019-11-22
    • 2017-10-14
    • 1970-01-01
    • 2018-11-27
    • 1970-01-01
    • 2016-06-17
    • 2017-05-14
    相关资源
    最近更新 更多