Search code examples
pythonamazon-web-servicesaws-lambdaamazon-vpc

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


I am following tutorial to write to VPS database at https://docs.aws.amazon.com/lambda/latest/dg/services-rds-tutorial.html

I get down to "Create the Lambda function". I have a folder in home called aws_mysql_tutorial/app.py and also init.py which is the app.py the tutorial shows to run the db commands. I did not find a command line way to zip this file or folder, but I see the argument --zip-file fileb://app.zip and have no idea what to zip and where to put it...I do not know what 'fileb' path means.

How can I satisfy aws lambda create-function?

after making a 7zip file, I get the following error

$ 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

Solution

  • Looks like the step that creates a zip file is missing in the documentation. 7z is not supported here. You must create a .zip. You can use the following command to zip the lambda handler:

    zip -r app.zip app.py
    

    Then you should be able to execute the create-function successfully.