In my case below are the Lambda Runtime configurations.
Runtime - Python3.12 Architecture - arm64
I have attached 2 layers to my lambda function. Each layer has a set of packages as below.
| layer1 | layer2 |
|---|---|
| SQLAlchemy==2.0.21 | country-converter |
| aws-xray-sdk | urllib3 |
| boto3 | psycopg2-binary |
| botocore | psycopg2 |
| aws-lambda-context==1.1.0 | |
| requests | |
| cryptography |
My function of the lambda is whenever it receives a request it call a RDS (postgres DB) to fetch the data, process it and put in queue. I am using SQLALchemy to establish the connection with DB. It seems I am facing an issue while running create_engine method and I am not sure what is the reason for that. In my cloudwatch I could see the below error always.
Runtime.ImportModuleError: Unable to import module 'sample.main': No module named 'psycopg2._psycopg
NOTE: All the above lambda, layer and queue creation are made through terraform So, previously I am using Python3.8 and Architecture as X86_64 processor. So, now as a part of recent changes in code I also made changes in Lambda Runtime configurations to Python3.12 and arm64.
I have tried for different versions of the package as well as tried for Python3.11 version I am ending up getting the same error.