0
votes

I have the following CI/CD setup with Gitlab for deploying my lambda function

enter image description here

When it runs no error happens but when I try executing the function I receive the "failed with error [Errno 13] Permission denied: '/var/task/lambda_function.py" error. Is there any way to solve this? I've found this article in which aws suggests using chmod to give file permissions, but it didn't help.

BTW: I've ran the same commands locally in my machine and no error happens when running the function

Thanks in advance for any answer.

UPDATE: CloudWatch Logs below

enter image description here

1
The error occurs when you invoke your function or when you are executing the update-function-code? - Marcin
Whenever I invoke the function. The update-function-code happens normally - Aylton Almeida
Can you check CloudWatch Logs for possibly more error messages? - Marcin
Just updated it - Aylton Almeida
This is a similar question. You can check out my answer here! stackoverflow.com/a/68037739/11839249 - Han

1 Answers

1
votes

I think you have similar trouble like this one and another here on stackoverflow as well. You have to manually set the permissions of the zip file.

quoting from the bug

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.

So to fix the issue, simply set the expected permissions before deflation, in Lambda's case, something like 755 will do.