调用AWS S3时添加了自定义lambda层导致SSL授权错误 [英] Added custom lambda layer caused SSL authorization error when calling AWS S3

查看:112
本文介绍了调用AWS S3时添加了自定义lambda层导致SSL授权错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Python 3.8中为AWS lambda创建了一个lambda层,但是,在我的lambda函数中调用S3时,这会导致SSL授权错误(即使lambda层中的任何包都没有导入到主要的lambda函数中)

以下代码在未添加lambda层时成功,但是在添加我的自定义lambda层时失败.

  import boto3def lambda_handler(事件,上下文):c1 = boto3.client("s3")lst = c1.list_buckets()打印(第一)返回 {'statusCode':200,'body':'Lambda,你好!} 

注意,我什至没有在这里导入我的包

可能是什么原因,在这种情况下我应该如何调试?

解决方案

似乎在Python虚拟环境中自动生成的某些程序包与AWS Lambda所使用的程序包冲突.在删除了这些自动生成的程序包并仅保留必需的程序包(尝试和错误)之后,我便能够将程序包加载到AWS Lambda中.

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?

解决方案

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.

这篇关于调用AWS S3时添加了自定义lambda层导致SSL授权错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆