AWS Lambda Console - Upgrade boto3 version

南笙酒味 提交于 2020-01-03 17:49:31

问题


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 ?


回答1:


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.




回答2:


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__)


来源:https://stackoverflow.com/questions/53736963/aws-lambda-console-upgrade-boto3-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!