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

后端 未结 7 2174
梦如初夏
梦如初夏 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:54

    Amazon's Serverless Application Model (SAM) provides a build command that can bundle arbitrary python dependencies into the deployment artifact.

    To be able to use the requests package in your code, add the dependency to your requirements.txt file:

    requests==2.22.0
    

    then run sam build to get an artifact that vendors requests. By default, your artifacts will be saved to the .aws-sam/build directory but another destination directory can be specified with the --build-dir option.

    Consult SAM's documentation for more info.

    0 讨论(0)
提交回复
热议问题