Code Monkey home page Code Monkey logo

cx_oracle-lambda-layer's Introduction

Introduction

This repo provides the instructions and the cx_Oracle layer (python 3.7 version) that can be used as a Lambda Layer on AWS. To skip the steps and use the lambda layer directly, download the zip file from https://drive.google.com/file/d/15gYtlo2qzL_OFjICSfNLkNSZ1IFF_1tK/view?usp=sharing.

About cx_Oracle:

cx_Oracle is a Python extension module that enables access to Oracle Database. See the cx_Oracle’s documentation. Here are the steps of how to create a cx_Oracle lambda layer (steps referenced from https://github.com/dennisoft/cxoracle).

Steps to create cx_Oracle layer

  1. EC2 Instance

    • Launch an Amazon EC2 Instance with Amazon Linux 2 AMI.The reason for using Amazon Linux 2 is that it comes with Python 3.7 available in the repositories.
    • Now you can connect to your Linux Instance using an SSH Client and start building the AWS Lambda Layer.
  2. Install and configure the AWS CLI.

  3. Update the existing system packages and install Python 3.7

     $ sudo yum update -y 
     $ sudo yum install python3 -y
    
  4. Create a working directory and structure it by creating the "python" and "lib" folders which are required for a Python Layer.

     $ mkdir ~/my_layer
     $ cd ~/my_layer
     $ mkdir python/ lib/
    
  5. Install the "cx_Oracle" module using "pip-3.7" under "python/" directory. The function code will access it without additional configuration.

    $ pip-3.7 install cx_Oracle -t python/

  6. Download the Oracle Instant Client (version 18.5 Basic Light) and extract the contents to the "lib/" directory.

     $ wget https://download.oracle.com/otn_software/linux/instantclient/185000/instantclient-basiclite-linux.x64-18.5.0.0.0dbru.zip -O oracle.zip
     $ unzip -j oracle.zip -d lib/
    
  7. Install the "libaio" library and copy it to the "lib/" folder of the layer. This library is preinstalled in Amazon Linux 2, if you are using it ycan skip the installation.

    $ (optional) sudo yum install libaio -y
    $ cp /lib64/libaio.so.1 lib/libaio.so.1
    
  8. Create a ZIP archive with "python/" and "lib/" folders.

    $ zip -r -y layer.zip python/ lib/
    
  9. Create a layer using the lambda layer zip file

  10. Upload the lambda layer to AWS and add environment variable to the lambda function:

    LD_LIBRARY_PATH = /var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib:/opt/python
    

cx_oracle-lambda-layer's People

Contributors

wajuqi avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

haihpse150218

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.