AWS Lambda to Firestore error: cannot import name 'cygrpc'

On my AWS Lambda Python 3.6 function I'd like to use Google Firestore (Cloud Firestore BETA) for caching purposes, but as soon as I add

from import firestore

to my Python script and upload ZIP to AWS Lambda function, Lambda test come back with error

Unable to import module 'MyLambdaFunction': cannot import name 'cygrpc'. 

AWS CloudWatch log doesn't contain any details on the error, just that same error message.

Lambda function works great on my local dev machine (Windows 10), and I can write to Firestore fine. It also works on AWS if I comment out the import and all Firestore related lines.

Any tips how I could go about solving this?

Answers 1

  • The python client for Firestore relies on the C-based implementation of GRPC. This appears not to work by default in AWS Lambda.

    Node.js users have reported similar problems and they've documented a workaround of building a docker image.

    This should be similar to any getting any other python package that requires native code to work. Perhaps something like this method for getting scikit to work?

    I hope this is enough to get you going in the right direction, but unfortunately I don't know anything about AWS Lambda :-(.

Related Articles