I'm trying to create an AWS Lambda function in Python to connect to an Oracle Database (for now, just a test connection). But I'm not got success to complete the flow. Every time I see this error message:
{
"errorMessage": "Unable to import module 'lambda_function': No module named 'cx_Oracle'",
"errorType": "Runtime.ImportModuleError"
}
I've created a virtualenv at Ubuntu WSL, install the Oracle InstantClient on the lib folder, install cx_oracle by pip at sites-package folder, and create my lambda function at the same folder, zip everything, upload at my S3 and put to run.
Can anyone help me?
My code:
import cx_Oracle
# Yeah, you need this
with open('/tmp/HOSTALIASES', 'w') as f: f.write(f'{os.uname()[1]} localhost\n')
# Oracle away!
def lambda_handler(event, context):
return str(
cx_Oracle.connect(
'username',
'password',
cx_Oracle.makedsn(
'rds.amazonaws.com', 1521, 'SOME_SID',
)
).cursor().execute('SELECT 42 FROM DUAL').fetchone()
)
My sites-package folder:

** My lambda config: **


