AnsweredAssumed Answered

Mgmt_api_lib python modules in AWS Lambda

Question asked by Keith Richards Employee on Dec 30, 2016

Hi,

 

I'm trying to use the example mgmt_api_lib and addAccessRule.py Python code within AWS Lambda  (python_bundle_1_2.zip).

 

I'm no developer and minimal scripting experience means I'm falling at the first hurdle. I need to upload the code I want to run (addAccessRule.py) and all of its dependencies to the AWS web interface. The AWS help page describes the way to create the deployment package is to use :

pip install <module name> -t <my project directory>

 

I unzipped the python_bundle_1_2.zip and the module I want to use, addAccessRule, has a structure as follows:

/add_access_rule/

     addAccessRule.py

     /mgmt_api_lib

          __init__.py

          api_exceptions.py

          api_responses.py

          cp_mgmt_api.py

 

Whenever I try installing this into a deployment package (instructions from AWS Lambda website suggest this is how to create the necessary package with all dependencies)

I see the following:

richardsk$ pip install addAccessRule.py -t ~/project/

Collecting addAccessRule.py

  Could not find a version that satisfies the requirement addAccessRule.py (from versions: )

No matching distribution found for addAccessRule.py

 

I don't understand packaging/building so I'm not sure what I should do to use this sample code. The addAccessRule.py contains a line :

from mgmt_api_lib import *

 

Fundamentally, AWS Lambda expects all python files needed to run my function in a single directory - any thoughts on how to do this gratefully received!

 

Keith

Outcomes