Skip to main content

Run your local python AWS Lambda locally and deploy to S3.

Project description

Python AWS Local Lambda
Easily test and deploy your AWS Lambda function.

Requirements

Python 2.7.x
pip
AWS CLI
AWS Account (For deploying)
*nix based OS (Not tested on Windows)
Since AWS currently only supports Python 2.7, you must ensure your function is tested and working in Python 2.7 before deploying.

Installation

Installation should be done using pip: pip install pylambda

Once installed, make sure you setup the AWS CLI by following: http://docs.aws.amazon.com/cli/latest/userguide/installing.html

Getting Started

Once installed you can run pylambda from the console.

Run pylambda -h to see help options.

Running Your Lambda

To run your lambda function, use the following command:

pylambda run my_lambda_function.py -e event.json -n handler

my_lambda_function.py = The python file containing your lambda function.
event.json = The json event sent to your python function. See http://docs.aws.amazon.com/lambda/latest/dg/python-programming-model-handler-types.html
handler = The name of the function that lambda should call. The event.json is passed to this function if provided.
Arguments:

file : the name of the python file that contains the lambda function. REQUIRED
-e, --event : the json file that contains the event data. Must be a parsable json file. OPTIONAL
-n, --name : the name of the function that should be called by lambda. Default 'handler'. OPTIONAL
Deploying to S3

To deploy your code as a zip to S3 navigate to the folder where your lambda function is contained and run:

pylambda deploy s3://mybucket/ -n my_lambda_function

s3://mybucket/ = The location of your S3 bucket. This should follow the AWS CLI for S3 locations.
my_lambda_function = The name of the zip file.
NOTE: you must have a proper requirements.txt within the same folder as your lambda function if you are using external libraries installed with pip. The deploy functionality will automatically bundle in these dependencies before uploading.

Arguments:

s3_bucket : the location of your S3 bucket. Must follow the AWS CLI format. REQUIRED
-n, --name : the name of the zip file that will be uploaded to S3.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pylambda-0.1.1-py2.py3-none-any.whl (7.9 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page