Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import requests on AWS Lambda for python 3.8

The trick to use requests from botocore.vendored no longer works with Python 3.8 on AWS Lambda which I assume includes the latest botocore-1.13. This version no longer embeds requests. Importing it works but the package is actually empty.

[ERROR] AttributeError: module 'botocore.vendored.requests' has no attribute 'post'

Is there a way to import requests on native lambda? It's a basic and it would be a pain to go through the process of packaging the code for very simple Lambda.

Alternatively, anyone has another trick to call API-Gateway without requests?

like image 619
Vincent Alvo Avatar asked Nov 26 '22 23:11

Vincent Alvo


1 Answers

Oh wow, I guess this is a 'breaking-change' on AWS Lambda that we rarely see.

AWS have warned about this before, there's a few options:

  • Use Serverless Framework and that serverless-python-requirements plugin
  • See if the Python3.7 Lambda Layer for requests from this repo works for Python3.8
  • Package it yourself using lambci for python3.8
like image 104
keithRozario Avatar answered Nov 28 '22 11:11

keithRozario