4

I am running an AWS Lambda function that uses one layer with snowflake-connector-python.

To create the layer I use:

docker run -v <your dev directory>:/lambda -it --rm ubuntu
apt-get update
apt-get install python3-pip 
apt-get install zip
cd lambda
mkdir -p temp/python
cd temp/python
pip3 install snowflake-connector-python -t .
cd ..
zip -r9 ../snowflake-connector-python.zip .

The lambda returns:

"errorMessage": "Unable to import module 's3PutLambda': /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /opt/python/cryptography/hazmat/bindings/_rust.abi3.so)",
  "errorType": "Runtime.ImportModuleError",
  "requestId": "baa60d07-c9bb-4b32-a38f-3158eb50da09",
  "stackTrace": []

I tried also some other solutions, such as adding to the zip:

pip3 install cryptography==3.4.8
pip3 install bcrypt==3.2.2

The same error was raised.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
mrc
  • 2,845
  • 8
  • 39
  • 73

2 Answers2

4

Finally solved, you need to downgrade snowflake-connector-python version and install it using platform manylinux2010_x86_64.

pip installs packages from latest wheel unless you specify wheels version. The Python library packages I used were newer than the ones in runtime in Lambda backend containers.

If you specify manylinux2010 platform when installing the connector it fixes the issue.

The command I used is:

pip3 install --platform manylinux2010_x86_64 --implementation cp --python 3.8 --only-binary=:all: 
--upgrade --target . snowflake-connector-python==2.7.9

Obs: I have not tested it with higher snowflake-connector-python versions, neither with higher python versions. I use Python 3.8 runtime in AWS Lambda.

mrc
  • 2,845
  • 8
  • 39
  • 73
0

I recently encountered the exact same issue, and I managed to resolve it using a technique similar to what was suggested by @mrc back in 2017. To rectify the situation, I added the snowflake-connector-python==2.7.9 library into a dummy virtual environment, which is then utilized to generate my Lambda layer zip folder. I accomplished this by running the following command::

pip3 install \
--platform manylinux2010_x86_64 \
--implementation cp \
--only-binary=:all: --upgrade \
--target venv/lib/python3.10/site-packages/ \
 snowflake-connector-python==2.7.9 boto3>=1.26.153 botocore>=1.29.153

It's essential to include both boto3 and botocore libraries, and also, it's crucial to use python3.10, as elucidated in this comment: link.

pass0s
  • 41
  • 4