Lambda is failing with error "File is not Zip File"

0

I am working on a DeepLens project that is due in a few days, and it was working a last week; however, now I am getting these error messages when I run my DeepLens project. I am seeing these error messages in the CloudWatch logs, and these messages keep repeating.

[2021-04-15T18:03:46.805-04:00][FATAL]-lambda_runtime.py:140,Failed to import handler function "lambda_function.lambda_handler" due to exception: File is not a zip file
[2021-04-15T18:03:53.679-04:00][FATAL]-lambda_runtime.py:380,Failed to initialize Lambda runtime due to exception: File is not a zip file

I got this lambda function from the DeepLens recipe "Worker Safety" (https://www.awsdeeplens.recipes/300_intermediate/310_worker_safety/312_extend_sample_project/). I have a feeling it has something to do with these lines of code even though it was working only a week ago.

boto_dir = '/tmp/boto_dir'
if not os.path.exists(boto_dir):
os.mkdir(boto_dir)
urllib.urlretrieve("https://s3.amazonaws.com/dear-demo/boto_3_dist.zip", "/tmp/boto_3_dist.zip")
with zipfile.ZipFile("/tmp/boto_3_dist.zip", "r") as zip_ref:
zip_ref.extractall(boto_dir)
sys.path.append(boto_dir)

Has anyone experienced this? Can someone please let me know what is going wrong?

I will greatly appreciate any help I can receive.

asked 4 years ago469 views
1 Answer
0

I figured out the issue! I realized that boto3 is already installed on the device with the new software, so I didn't need those lines of code anymore. You can just import boto3 automatically.

answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions