我正在尝试使用以下命令创建 AWS Lambda 函数
aws lambda create-function \
--function-name foo\
--runtime nodejs\
--role lambda_basic_execution \
--handler asdf --zip-file "fileb:://boom.zip"
我的目录中有一个名为“boom.zip”的文件。但我无法使用上述命令进行部署。
我收到的失败消息是
--zip-file 必须是带有 fileb:// 前缀的文件。
有人有使用 AWS CLI 创建 lambda 函数的工作示例吗?
文件规范中有一个额外的冒号“:”。
$ aws lambda create-function --function-name foo --runtime nodejs --role lambda_basic_execution --handler asdf --zip-file "fileb:://boom.zip"
--zip-file must be a file with the fileb:// prefix.
Example usage: --zip-file fileb://path/to/file.zip
$ aws lambda create-function --function-name foo --runtime nodejs --role lambda_basic_execution --handler asdf --zip-file "fileb://boom.zip"
Error parsing parameter '--zip-file': Unable to load paramfile fileb://boom.zip: [Errno 2] No such file or directory: 'boom.zip'
在 mac 上我必须使用绝对路径,但添加到前缀中实际上有 3 个斜杠。
前缀:
fileb://
路径
/Users/myuser/Apps/folder/zips/file.zip
完成
fileb:///Users/myuser/Apps/folder/zips/file.zip
我在 Ubuntu 18.04 上遇到了同样的问题,诀窍是用双引号
fileb:///
括住函数名称和 "
。
aws lambda update-function-code --function-name "FUNCTION" --zip-file "fileb:///an/absolute/path/to/your/lambda/FUNCTION.zip"
对我来说,问题发生(在 Windows 中)是因为我没有正确创建 zip 文件。我使用
winrar
工具创建了.rar
文件,将扩展名更改为.zip
,并尝试以@helloV
所说的相同方式上传zip(没有双::
),但我得到了相同的结果错误信息。如果您使用的是 Windows,请务必遵循 this 指南(适用于 golang),或使用任何其他合适的工具创建正确的 zip 文件并再次尝试该命令。
在 Mac OS Monterey 上,我做了以下操作并且成功了。坦克 Devorein 和 baduker