Python at AWS Lambda: `requests` from botocore.vendored deprecated, but `requests` not available

后端 未结 7 2190
梦如初夏
梦如初夏 2021-02-07 16:07

I\'ve got a Python script for an AWS Lambda function that does HTTP POST requests to another endpoint. Since Python\'s urllib2.request, https://docs.python.org/2/li

7条回答
  •  不思量自难忘°
    2021-02-07 16:44

    Answer 2020-06-18

    I found a nice and easy way to use requests inside AWS Lambda functions!

    Open this link and find the region that your function is using:
    https://github.com/keithrozario/Klayers/tree/master/deployments/python3.8/arns

    Open the .csv related to your region and search for the requests row.
    This is the ARN related to requests library:
    arn:aws:lambda:us-east-1:770693421928:layer:Klayers-python38-requests:6

    So now in your lambda function, add a layer using the ARN found.
    Obs.: make sure your Python lambda function runtime is python3.8.

提交回复
热议问题