I have a zip file on S3. I need to use /tmp
folder of a Lambda for lazy-loading that I am using to store the zip file and then I need the folder to contain the unzipped contents. I am using Python for the operations. Below is the code:
import sys
import zipfile
import subprocess
s3 = boto3.resource('s3')
s3.meta.client.download_file('bucket', 'dependencies/dependencies.zip', '/tmp/dependencies.zip')
output = subprocess.check_output('unzip /tmp/dependencies.zip -d /tmp/')
print("Output: ", output.decode('utf-8'))
I am getting the error: No such file or directory: 'unzip /tmp/dependencies.zip -d /tmp/': 'unzip /tmp/dependencies.zip -d /tmp/'
Unknown application error occurred
I have my code outside the lambda_handler()
for cold-start. From this I not even sure that the zipped file has been copied to /tmp
directory since that line didn't throw any error, and also I am not able to unzip the contents. I tried removing the /
in front of tmp
and that didn't help either. Where am I going wrong?