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!

질문됨 일 년 전609회 조회
3개 답변
2
수락된 답변

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
전문가
답변함 일 년 전
profile pictureAWS
전문가
검토됨 일 년 전
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
전문가
답변함 일 년 전
0

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

profile picture
전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠