14
votes

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?

3
In your snippet, you have "fileb:://" which is incorrect based on the error message.Matt Houser
I haven't got this working either. The example I'm working from has a longer --role arn:aws:iam::$account_id:role/service-role/lambda_basic_execution per aws.amazon.com/blogs/compute/…MarkHu
were you able to resolve this?Ani
double check your zip file. I just ran into this which got me to this thread, and come to find out, my build created an empty zip due to an errorScott

3 Answers

13
votes

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'
4
votes

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
1
votes

I've had the same issue on Ubuntu 18.04 and what did the trick was enclosing both the name of the function and the fileb:/// with double " quotes.

aws lambda update-function-code --function-name "FUNCTION" --zip-file "fileb:///an/absolute/path/to/your/lambda/FUNCTION.zip"