Skip to main content

run code or subprocess on aws lambda invoke context

Project description

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

Project details


Download files

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

Source Distribution

lambda-run-0.0.3.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

lambda_run-0.0.3-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file lambda-run-0.0.3.tar.gz.

File metadata

  • Download URL: lambda-run-0.0.3.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for lambda-run-0.0.3.tar.gz
Algorithm Hash digest
SHA256 74a482a41d013fc296553559cbed67846f764fceb5c510e800c67176c36d05bb
MD5 383d50173f5e45ed2477c97123a810c5
BLAKE2b-256 7425b735130402d6b8801f601065a87c59bd6a7afc6f91471bc661ea578e7130

See more details on using hashes here.

File details

Details for the file lambda_run-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: lambda_run-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for lambda_run-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b960a0f74bf1451b55402d2841f466999ac8e086389812fe566a7e37a6aebd15
MD5 1f3a00af1dcea94ef89eb98ceb6a60a6
BLAKE2b-256 ec2a4b366b60ab73bba22c0b390b8448f8b67a6cb9c4b6bc771ba6abd106f177

See more details on using hashes here.

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