2

Please see the screenshots in particular after reading.

I am deploying a python script on AWS Lambda which uses the package impyla which has a dependency on the package bitarray.

from impala.dbapi import connect

My python file is called authorize_ingress.py which has a function called handle_authorize_ingress(event, context) which are properly configured. See the screenshots below:

My function's file:

function

The handler in lambda specified:

handler

The handler in code itself:

handler

and my zip file has everything in the root (and not nested within a directory):

file

The package bitarray is installed automatically by impyla:

bitarray

Every single time, I am met with this response:

response

As of now, I have tried to:

  • The package was generated with zip -r option.
  • The files are in the root of the zip and not nested within a directory.
  • The function works perfectly fine locally.
  • I have tried both virtualenv and simply installing the dependencies in a packages/ path but no luck

Any ideas what I might be doing wrong? I generated my deployment package following AWS' Lambda Deployment Guide. Any help would be appreciated, thank you!

Humza Khan
  • 733
  • 1
  • 6
  • 13
  • Looks like you didn't pack `bitarray` into the deployment package. – jellycsc Jul 17 '20 at 00:45
  • @jellycsc that's the thing, it is there. I am running the exact same package in the `venv` locally and it runs fine. When the exact same package is deployed, it cannot seem to find it. – Humza Khan Jul 17 '20 at 00:46
  • If you tell me the exact python dependencies, I can bake a layer zip for you. – jellycsc Jul 17 '20 at 00:48
  • @jellycsc I depend on only two main dependencies. (1) impyla: https://pypi.org/project/impyla/ (2) boto3: https://pypi.org/project/boto3/ `bitarray` is a dependency of `impyla` and is installed along with it. Thank you! – Humza Khan Jul 17 '20 at 00:50

1 Answers1

1

Here you go. You can download this lambda layer through this gdrive link. This layer is compatible with Python 3.8, so make sure you select the correct lambda runtime.

If you are curious to know how I generated this lambda layer, here is a list of basically what I did:

  • Serverless Framework
  • serverless-python-requirements plugin
  • docker
  • serverless.yml
service: serverless-example

provider:
  name: aws
  runtime: python3.8
  region: us-east-1
  profile: dummy

functions:
  dummy:
    handler: dummy.handler

plugins:
  - serverless-python-requirements

custom:
  pythonRequirements:
    dockerizePip: non-linux
    layer: true
  • requirements.txt
impyla==0.16.2

Then simply do sls package -p pkg. The layer named pythonRequirements.zip will be ready in a minute under .serverless directory.

jellycsc
  • 10,904
  • 2
  • 15
  • 32
  • 1
    I don't know why some people get upset about my answer :D, let me know the reason please. – jellycsc Jul 17 '20 at 01:14
  • 1
    I didn't downvote your answer but saw this comment and believe the reason is that typically people don't want to have to rely on another framework (serverless) to solve a problem like this. Honestly, it's a pretty big ask if someone has a concern and the answer is to learn a new framework... a better answer would be to explain what is wrong and how it could be solved using existing constraints, then you could certainly link to serverless and say it may be easier if you are familiar with framework x, etc. – hurlbz Jan 30 '21 at 16:24