gpt4 book ai didi

amazon-web-services - 获取现有 lambda 的 AWS cloudformation

转载 作者:行者123 更新时间:2023-12-03 07:36:58 25 4
gpt4 key购买 nike

有什么方法可以获取 lambda 的云信息吗?我知道您可以使用 CloudFormer 从现有 AWS 资源创建 AWS CloudFormation 模板。而且,在我问这个问题时,cloudformer 正处于测试模式(AWS CloudFormer 0.41(测试版))。同时遵循documentation ,我找不到为我的 lambda 创建 cloudformation 的方法

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

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

最佳答案

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

gem 安装 ruby​​cfn

将以下文件保存到 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

关于amazon-web-services - 获取现有 lambda 的 AWS cloudformation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51706607/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com