Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda Console - Upgrade boto3 version

I am creating a DeepLens project to recognise people, when one of select group of people are scanned by the camera.

The project uses a lambda, which processes the images and triggers the 'rekognition' aws api.

  • When I trigger the API from my local machine - I get a good response

  • When I trigger the API from AWS console - I get failed response

Problem

After much digging, I found that the 'boto3' (AWS python library) is of version:

  • 1.9.62 - on my local machine

  • 1.8.9 - on AWS console

Question

Can I upgrade the 'boto3' library version on the AWS lambda console ?? If so, how ?

like image 695
Deep Avatar asked Dec 12 '18 06:12

Deep


2 Answers

You can achieve the same with either Python function with dependencies or with a Virtual Environment.

These are the available options other than that you also try to contact Amazon team if they can help you with up-gradation.

like image 128
Shivang Agarwal Avatar answered Sep 29 '22 06:09

Shivang Agarwal


If you don't want to package a more recent boto3 version with you function, you can download boto3 with each invocation of the Lambda. Remember that /tmp/ is the directory that Lambda will allow you to download to, so you can use this to temporarily download boto3:

import sys
from pip._internal import main

main(['install', '-I', '-q', 'boto3', '--target', '/tmp/', '--no-cache-dir', '--disable-pip-version-check'])
sys.path.insert(0,'/tmp/')

import boto3
from botocore.exceptions import ClientError

def handler(event, context):
    print(boto3.__version__)
like image 27
user1998671 Avatar answered Sep 29 '22 05:09

user1998671