How can I create an AWS Lambda function using the AWS CLI?

余生颓废 提交于 2019-12-12 08:31:55

问题


I am trying to create an AWS Lambda function using the command

aws lambda create-function \
  --function-name foo\
  --runtime nodejs\
  --role lambda_basic_execution \
  --handler asdf --zip-file "fileb:://boom.zip"

I have a file called boom.zip available in the directory. But I cannot deploy using the above command.

The failure message I get is

--zip-file must be a file with the fileb:// prefix.

Does anyone have a working example to create a lambda function using the AWS CLI?


回答1:


You have an extra colon ':' in the file spec.

$ 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'



回答2:


On mac I had to use absolute path, but added to the prefix there are actually 3 slashes.

Prefix:

fileb://

Path

/Users/myuser/Apps/folder/zips/file.zip

Complete

fileb:///Users/myuser/Apps/folder/zips/file.zip


来源:https://stackoverflow.com/questions/34362805/how-can-i-create-an-aws-lambda-function-using-the-aws-cli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!