为现有的 lambda 获取 AWS cloudformation

Get AWS cloudformation for an existing lambda

有什么方法可以获取 lambda 的 cloudformation 吗? 我知道您可以使用 CloudFormer. And also, cloudformer is in beta mode (AWS CloudFormer 0.41 (Beta)) at the time I am asking this question. While following the documentation 从现有 AWS 资源创建 AWS CloudFormation 模板,但我找不到为我的 lambda

创建 cloudformation 的方法

I have selected everything while creating the cloudformation but the template contains no lambdas.

是不支持还是我遗漏了什么? 如果不支持,请问是什么原因?

如果将 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