15

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?

2
  • In your snippet, you have "fileb:://" which is incorrect based on the error message. Commented Dec 18, 2015 at 21:20
  • 1
    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/… Commented Jan 2, 2018 at 4:40

5 Answers 5

13

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'
Sign up to request clarification or add additional context in comments.

3 Comments

Do we need to rename the .zip file name with the fileb::// prefix? Or is this just to be prepended while mentioning in the --zip-file option?
@AniruddhaRaje don't rename, it is not a valid file name. Just prepend it when using --zip-file option.
Thanks! Got this working, --zip-file took the Absolute path to the .zip file
5

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 Comment

aws should clarify that this fileb:// is not an example of an s3 bucket. if you're on mac, use Complete from this post ^ :pointup: ... to get the full path use pwd.
1

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"

Comments

1

For me, the issue occurred (in windows) because I didn't create the zip file correctly. I used the winrar tool to create the .rar file, changed the extension to .zip, and tried to upload the zip in the same way @helloV said (without double ::), but I got the same error message. If you are in windows make sure to follow this guide (for golang), or use any other suitable tool to create a correct zip file and try the command out again.

Comments

0

On Mac OS Monterey, I did following and it worked. Tanks Devorein and baduker

  1. Ensured zip file downloaded properly by checking ls -lart
  2. And put the path in quotes "" (may not be necessary)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.