0

我在创建将从本地计算机创建 AWS lambda 函数的请求时遇到问题。这是我要发送的内容:

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)

zip_file 的位置在文件系统上是可以的。我想在不使用 S3 的情况下从本地文件系统上传 lambda 内容(我看到也有一种方法可以从 S3 做到这一点)。

我得到的错误是:

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)

任何帮助都会很棒。

谢谢,巴基尔

4

1 回答 1

2

我想,你已经发现了,但只是为了回答问题,你应该做的是:

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)

根据Aws::Lambda::Client文档,选项:codeTypes::FunctionCode类型,其中zip_fileString. The contents of your zip file containing your deployment package.

于 2017-03-20T15:36:41.953 回答