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?
In the Amazon S3 console, choose your S3 bucket, choose the file that you want to open or download, choose Actions, and then choose Open or Download. If you are downloading an object, specify where you want to save it. The procedure for saving the object depends on the browser and operating system that you are using.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With