Skip to main content

lambda-run

run python code or shell commands on aws lambda invoke context

install:

# use bare package for production
$ pip install lambda-run

# use to install dev dependencies
# needed to execute commands from cli 
$ pip install lambda-run[cli]

usage:

wrap your lambda function like this:

import lambda_run

# wrapping will catch 'lambdaRun' events
# otherwise it will pass the event forward
@lambda_run.wrap_handler
def lambda_handler(event, context):
    # your regular lambda handler...
    print(event, context) 
    return 'OK' 

execute commands from cli:

# set AWS env vars for boto3
export AWS_PROFILE=profile AWS_DEFAULT_REGION=eu-west-1

# Usage: lambda-run [OPTIONS] FUNCTION_NAME [PAYLOAD]

# attach payload directly as last argument
lambda-run -m python my-lambda 'import sys; print(sys.path)'

# or by posix pipe/redirect, for example: 
# pipe it
echo 'import sys; print(sys.path)' | lambda-run -m python my-lambda 

# oneliner redirect
lambda-run -m shell my-lambda <<<'python manage.py createsuperuser'

# or multiline
lambda-run -m python my-lambda <<EOF
for i in range(10):
    print(i)
EOF

# or file content
lambda-run -m shell my-lambda <bash-script.sh

Release files for lambda-run 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lambda-run 0.0.3
File Size Uploaded
lambda-run-0.0.3.tar.gz 3.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lambda-run 0.0.3
File Interpreter ABI Platform
lambda_run-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / lambda-run-0.0.3.tar.gz

Download URL lambda-run-0.0.3.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
74a482a41d013fc296553559cbed67846f764fceb5c510e800c67176c36d05bb
BLAKE2b-256 checksum
How to use checksums
7425b735130402d6b8801f601065a87c59bd6a7afc6f91471bc661ea578e7130
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.5

Release files / lambda_run-0.0.3-py3-none-any.whl

Download URL lambda_run-0.0.3-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b960a0f74bf1451b55402d2841f466999ac8e086389812fe566a7e37a6aebd15
BLAKE2b-256 checksum
How to use checksums
ec2a4b366b60ab73bba22c0b390b8448f8b67a6cb9c4b6bc771ba6abd106f177
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page