user3822232
user3822232

Reputation: 315

Using snowflake in aws lamda by adding snowflake connector dependencies as layer

I am trying to add snowflake-connector-python version 2.7.9 as a layer in aws lambda. I am getting this error Unable to import module lambda_function: /lib64/libc.so.6: version GLIBC_2.28 not found (required by /opt/python/lib/python3.9/site-packages/cryptography/hazmat/bindings/_rust.abi3.so)

Steps I have tried docker run -v /Users/local/Documents/docker_test:/working -it --rm ubuntu

once inside i tried

  1. apt-get update
  2. then install python 3.9 using link https://exchangetuts.com/how-to-install-python39-on-linux-ubuntu-terminal-1639972230035814
  3. apt install python3-virtualenv
  4. virtualenv snowflake_test
  5. source snowflake_test/bin/activate
  6. python3 --version
  7. sudo apt install python3-pip
  8. python3 -m pip3 install --upgrade pip
  9. sudo apt-get install -y libssl-dev libffi-dev
  10. mkdir -p lambda_layers/python/lib/python3.9/site-packages
  11. cd lambda_layers/python/lib/python3.9/site-packages
  12. pip3 install snowflake-connector-python==2.7.9 -t .

Then i zip the /python/lib/python3.9/site-packages contents and create a layer in aws. And i function is simple

import json
import snowflake.connector

def lambda_handler(event, context):
    # TODO implement
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }

Some of things i had to do to get to this error

  1. I had to install cffi as i was getting No module named '_cffi_backend'
  2. Had to remove cyrptography dependecies as i had version 36 and reinstall again to get 38
  3. python3-virtualenv seems to install python 3.10.x version as well. So the docker image has both python 3.10 and 3.9. Snowflake doc says it only works with 3.9 I change the added alias to python and python3 to point to python3.9

How to i get this error /lib64/libc.so.6: version GLIBC_2.28 fixed ?

Upvotes: 0

Views: 1350

Answers (1)

André M.
André M.

Reputation: 1

I had a similar issue and had to specify an older cryptography version in the lambda layer (pip install cryptography==3.4.8). For me this solved the issue, hope this helps you too!

Upvotes: 0

Related Questions