ERROR PermissionError: [Errno 13] Permission denied: '/var/task/main.py'

Viewed 373

I have a python Lambda that returns this error. This function only read a json event and parse some fields. Stop. I can't paste here the lambda code. This lambda has always worked and with no changes stopped!!!

Lambda code is taken from a BitBucket repository.

enter image description here     

1 Answers

Have you by any chance updated the .zip package for lambda? The error might have something to do with the following:

The zip archive preserves file permissions, so if you have a 644 permissions file, deflate it and inflate it back up, you get 644 permissions for that file.

Try setting the expected permissions before deflation, in Lambda's case, 755 should do just fine.

Or... that JSON file the lambda reads might actually be in a folder and you're trying to read it.

Error 13 usually means you are trying to open a file, but your path is a folder.

Another possible reason for this might be the permission issues on the Lambda handler file.

Try this:

chmod 644 your_lambda_handler_file.py

And in the directory where your lambda code is, try this:

chmod 644 $(find . -type f)
chmod 755 $(find . -type d)
Related