Lambda gives error when trying to modify S3 files

0

I uploaded my python script and it s necessary folders in S3, and use it inside Lambda. Now, this script also should modify and move some files inside S3, but whenever it s trying to write anything it gives this error:"{ "errorMessage": "[Errno 30] Read-only file system: '/var/task/config/log/ex_140365708625664.log'", "errorType": "OSError", "requestId": "ad64b6d0-0228-4fa1-84b2-83c1bc4e50a7", "stackTrace": [...........". Now I tried to give it permissions and so on, but I am very new to AWS and don't know exactly what the problem is. Any help is appreciated, thank you!

  • What does your code that's accessing S3 look like? Also, does it run OK on your local machine with the right credentials and permissions set up?

  • @skinsman It runs fine on the local machine. Also tried it in different environments and works ok. It's a script that does some stuff, followed by moving some files to different folders and writing a log. The problem is not within the code, it's something about the permissions to write inside S3 by Lambda.

  • Yeah, it seems that the only writable folder is tmp. As I said in the post, the library which I am using is trying to write a log in a folder, which is not tmp and it also needs to move stuff around. So it seems that Lambda it's not such a good approach to my problem. Thank you everyone who answered!

asked a year ago526 views
3 Answers
2
Accepted Answer

Hi,

Is your Lambda function trying to write a log file into its file system? If so, according to the AWS documentation, /tmp is the only valid directory.

It acts as an ephemeral storage area that is preserved just for the lifetime of the execution environment, and it is usually used as a transient cache between invocations, but never as a place to store data permanently.

profile picture
EXPERT
answered a year ago
profile pictureAWS
EXPERT
reviewed a year ago
1

Hi,

it could be that your Lambda code (or one of its dependencies) has some logic which is writing a file to some temporary folders.

As lambda has only access to the tmp folder as a writable folder, your code or your dependency is not allowed to do so, hence the message.

If this is something you can control directly in your code, you may need to modify it. If it comes from a library, could be that Lambda may not be a fit for that case, unless you use a different library.

Hope it helps ;)

profile picture
EXPERT
answered a year ago
0

Is it possible to share the Lambda code and the IAM roles and policies attached to the Lambda?

profile picture
EXPERT
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions