Reputation: 51
This article was the closest to what I experienced: Connecting to Oracle RDS using AWS Lambda using Python. However, after following all of the steps, I am unable to get a successful result.
Steps on ami-aa5ebdd2 in us-west-2:
sudo yum -y install gcc
mkdir oracle_connect
source oracle_connect/bin/activate
virtualenv oracle_connect
pip install cx_Oracle
wget https://github.com/bumpx/oracle-instantclient/raw/master/instantclient-basic-linux.x64-12.2.0.1.0.zip
mv instantclient_12_2/* oracle_connect/lib/
cd oracle_connect
vi test.py # insert python code here
cp /lib64/libaio.so.1.0.1 lib
ln -s ./lib/libclntsh.so.12.1 ./lib/libclntsh.so
ln -s ./lib/libaio.so.1.0.1 ./lib/libaio.so.1
ln -s ./lib/libaio.so.1.0.1 ./libaio.so.1.0.1
ln -s ./lib/libaio.so.1.0.1 ./libaio.so.1.0.1
cd lib/python2.7/site-packages/
zip -r ~/oracle_connect.zip * .*
cd ~/oracle_connect/lib64/python2.7/site-packages/
zip -r ~/oracle_connect.zip * .*
cd ~/oracle_connect
zip --symlinks -r9 ~/oracle_connect.zip lib/*
zip ~/oracle_connect.zip test.py
The test code is just a cx_Oracle.connect(connection_string) within a lambda handler.
Any advice? I tried to give as much detail as possible. When I try to run this locally, it won't work until I setup: export LD_LIBRARY_PATH=/home/ec2-user/oracle_connect/lib
So I setup the environmental variable on the lambda as: LD_LIBRARY_PATH: /var/task/lib
Upvotes: 2
Views: 4205
Reputation: 51
So I finally got it working. I re-downloaded the instantclient-basic-linux.x64-12.2.0.1.0.zip from Oracle: http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html. I copied the files into the ~/oracle_connect/lib folder. I changed my symlinks to /var/task/lib/(filename) instead of the relative path, and removed the lambda environment variables. Everything works now.
Upvotes: 3