Added custom lambda layer caused SSL authorization error when calling AWS S3

ε祈祈猫儿з 提交于 2021-01-07 07:00:19

问题


I created a lambda layer for AWS lambda in Python 3.8, however, it is causing a SSL authorization error when calling S3 in my lambda function (even though no packages in the lambda layer are imported in the main lambda function)

The following code succeeded when no lambda layer is added, but failed when added my custom lambda layer.

import boto3

def lambda_handler(event, context):
    c1 = boto3.client("s3")
    lst = c1.list_buckets()
    print(lst)
    return {
        'statusCode': 200,
        'body': 'Hello from Lambda!'
    }

NOTE that I did not even import my package here

What could be the potential cause, how should I debug in this case?


回答1:


It appears that some packages that are auto-generated in the Python virtual environments conflict with what AWS Lambda uses. After removing these auto-generated packages and keeping only the required packages (trial and error), I was able to load my package in AWS Lambda.



来源:https://stackoverflow.com/questions/64635586/added-custom-lambda-layer-caused-ssl-authorization-error-when-calling-aws-s3

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