问题
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