解析参数“--zip-file”时出错:无法加载参数文件 fileb://app.zip:[Errno 2] 没有这样的文件或目录:'app.zip'

Error parsing parameter '--zip-file': Unable to load paramfile fileb://app.zip: [Errno 2] No such file or directory: 'app.zip'

我正在按照教程写入位于 https://docs.aws.amazon.com/lambda/latest/dg/services-rds-tutorial.html

的 VPS 数据库

我开始“创建 Lambda 函数”。我在家里有一个名为 aws_mysql_tutorial/app.py 的文件夹,还有 init.py,这是教程向 运行 显示的 app.py db 命令。我没有找到压缩此文件或文件夹的命令行方式,但我看到参数 --zip-file fileb://app.zip 并且不知道要压缩什么以及将它放在哪里...我不知道什么 'fileb'路径意味着。

怎样才能满足aws lambda create-function

制作 7zip 文件后,出现以下错误

$ aws lambda create-function --function-name CreateTableAddRecordsAndRead --runtime python3.8 --zip-file fileb://app.7z --handler app.handler --role arn:aws:iam:::role/lambda-vpc-role --vpc-config SubnetIds=subnet-,subnet-,SecurityGroupIds=sg-

--zip-file must be a zip file with the fileb:// prefix.
Example usage:  --zip-file fileb://path/to/file.zip

文档中似乎缺少创建 zip 文件的步骤。此处不支持 7z。您必须创建一个 .zip。您可以使用以下命令压缩 lambda 处理程序:

zip -r app.zip app.py

那么你应该可以成功执行create-function

在windows中,您可以打开文件夹导航并右键单击文件到'compress'。 aws cli 要求文件用引号引起来:

--zip-file "fileb://app.zip"

app.zip是命令运行所在目录下的一个文件,文件名前加fileb前缀即可。该教程有一个错误,它没有显示用引号引起来的文件名

不知道为什么!但是你需要在 fileb 之后有 3 个斜杠 ,像这样:

aws lambda update-function-code --function-name my-function \
--zip-file fileb:///path/lambdaFunc.zip

I had to deal with this today, took me a while to figure it out! even the dodumentation has it wrong!