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
Release history Release notifications | RSS feed
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 hashes)
Built Distribution
Close
Hashes for lambda_run-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b960a0f74bf1451b55402d2841f466999ac8e086389812fe566a7e37a6aebd15 |
|
MD5 | 1f3a00af1dcea94ef89eb98ceb6a60a6 |
|
BLAKE2b-256 | ec2a4b366b60ab73bba22c0b390b8448f8b67a6cb9c4b6bc771ba6abd106f177 |