6

Using Boto3, the python script downloads files from an S3 bucket to read them and write the contents of the downloaded files to a file called blank_file.txt.

My question is, how would it work the same way once the script gets on an AWS Lambda function?

franklinsijo
  • 17,784
  • 4
  • 45
  • 63
Jo Ko
  • 7,225
  • 15
  • 62
  • 120

2 Answers2

8

Lambda provides 512 MB of /tmp space. You can use that mount point to store the downloaded S3 files or to create new ones.

s3client.download_file(bucket_name, obj.key, '/tmp/'+filename)
...
blank_file = open('/tmp/blank_file.txt', 'w')

The working directory used by Lambda is /var/task and it is a read-only filesystem. You will not be able to create files in it.

franklinsijo
  • 17,784
  • 4
  • 45
  • 63
0

AWS Lambda functions get 500MB of temporary space in "/tmp" available for temporary storage while your function executes.

https://aws.amazon.com/lambda/faqs/

E.J. Brennan
  • 45,870
  • 7
  • 88
  • 116