{"id":1096,"hash":"aa0fc18c637b2e2738098862fe0f38909d04cb57ec428121c81a1d23fa379905","pattern":"Error &quot;Read-only file system&quot; in AWS Lambda when downloading a file from S3","full_message":"I'm seeing the below error from my lambda function when I drop a file.csv into an S3 bucket. The file is not large and I even added a 60 second sleep prior to opening the file for reading, but for some reason the file has the extra \".6CEdFe7C\" appended to it. Why is that?\n\n[Errno 30] Read-only file system: u'/file.csv.6CEdFe7C': IOError\nTraceback (most recent call last):\nFile \"/var/task/lambda_function.py\", line 75, in lambda_handler\ns3.download_file(bucket, key, filepath)\nFile \"/var/runtime/boto3/s3/inject.py\", line 104, in download_file\nextra_args=ExtraArgs, callback=Callback)\nFile \"/var/runtime/boto3/s3/transfer.py\", line 670, in download_file\nextra_args, callback)\nFile \"/var/runtime/boto3/s3/transfer.py\", line 685, in _download_file\nself._get_object(bucket, key, filename, extra_args, callback)\nFile \"/var/runtime/boto3/s3/transfer.py\", line 709, in _get_object\nextra_args, callback)\nFile \"/var/runtime/boto3/s3/transfer.py\", line 723, in _do_get_object\nwith self._osutil.open(filename, 'wb') as f:\nFile \"/var/runtime/boto3/s3/transfer.py\", line 332, in open\nreturn open(filename, mode)\nIOError: [Errno 30] Read-only file system: u'/file.csv.6CEdFe7C'\n\nCode:\n\ndef lambda_handler(event, context):\n\n    s3_response = {}\n    counter = 0\n    event_records = event.get(\"Records\", [])\n\n    s3_items = []\n    for event_record in event_records:\n        if \"s3\" in event_record:\n            bucket = event_record[\"s3\"][\"bucket\"][\"name\"]\n            key = event_record[\"s3\"][\"object\"][\"key\"]\n            filepath = '/' + key\n            print(bucket)\n            print(key)\n            print(filepath)\n            s3.download_file(bucket, key, filepath)\n\nThe result of the above is:\n\nmytestbucket\nfile.csv\n/file.csv\n[Errno 30] Read-only file system: u'/file.csv.6CEdFe7C'\n\nIf the key/file is \"file.csv\", then why does the s3.download_file method try to download \"file.csv.6CEdFe7C\"? I'm guessing when the function is triggered, the file is file.csv.xxxxx but by the time it gets to line 75, the file is renamed to file.csv?","ecosystem":"pypi","package_name":"amazon-s3","package_version":null,"solution":"Only /tmp seems to be writable in AWS Lambda.\n\nTherefore this would work:\n\nfilepath = '/tmp/' + key\n\nReferences:\n\nhttps://aws.amazon.com/blogs/compute/choosing-between-aws-lambda-data-storage-options-in-web-apps\nhttps://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/39383465/error-read-only-file-system-in-aws-lambda-when-downloading-a-file-from-s3","votes":142,"created_at":"2026-04-19T04:52:20.952068+00:00","updated_at":"2026-04-19T04:52:20.952068+00:00"}