[英]How to create AWS lambda function from local machine using AWS Ruby SDK
I'm having troubles creating request that will create AWS lambda function from local machine. 我在创建将要从本地计算机创建AWS lambda函数的请求时遇到了麻烦。 This is the content that I'm trying to send:
这是我要发送的内容:
require 'aws-sdk'
client = Aws::Lambda::Client.new(region: 'us-east-1')
args = {}
args[:role] = role
args[:function_name] = function_name
args[:handler] = handler
args[:runtime] = 'python2.7'
code = {}
code[:zip_file] = '/root/main.zip'
args[:code] = code
client.create_function(args)
Location of zip_file is ok on filesystem. zip_file的位置在文件系统上可以。 I want to upload lambda content from local filesystem without using S3 (I saw there is a way to do that from S3 also).
我想在不使用S3的情况下从本地文件系统上载lambda内容(我也看到有一种从S3做到这一点的方法)。
The error I'm getting is: 我得到的错误是:
lib/ruby/gems/2.0.0/gems/aws-sdk-core-2.5.11/lib/seahorse/client/plugins/raise_response_errors.rb:15:in `call': Could not unzip uploaded file. Please check your file, then try to upload again. (Aws::Lambda::Errors::InvalidParameterValueException)
Any help would be great. 任何帮助都会很棒。
Thanks, Bakir 谢谢,巴基尔
I guess, you've already found it out, but just for the sake of question to be answered here is what you should've done: 我想,您已经找到答案了,但是为了回答问题,这里您应该做的是:
require 'aws-sdk'
client = Aws::Lambda::Client.new(region: 'us-east-1')
args = {}
args[:role] = role
args[:function_name] = function_name
args[:handler] = handler
args[:runtime] = 'python2.7'
code = {}
code[:zip_file] = File.open('main.zip', 'rb').read
args[:code] = code
client.create_function(args)
According to Aws::Lambda::Client docs, option :code
is a Types::FunctionCode type, where zip_file
is a String. The contents of your zip file containing your deployment package.
根据Aws :: Lambda :: Client文档,选项
:code
是Types :: FunctionCode类型,其中zip_file
是String. The contents of your zip file containing your deployment package.
String. The contents of your zip file containing your deployment package.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.