This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

A tool for deploying Python projects to AWS Lambda.

Getting started

Authentication is left to boto3 so you can set it up just like the regular AWS CLI. You need an S3 bucket for temporary storage. For a quick tutorial on execution roles, see the official docs (of course you need one that can execute lambdas).

In a new folder, create mymodule.py.

def hello(*args):
    return "Hello, world!"

Then deploy the function (fill in your execution role resource name from the AWS console).

awslambda . mybucket --create hello mymodule.hello arn:aws:iam::xxxxxxxxxxxx:role/myrole

When awslambda is done, you can test your new function in the Lambda management console.

>From now on, if you make changes to the function, just run:

awslambda . mybucket --update hello

You can use as many options as you like (some shown here with short names).

awslambda . mybucket -u hello -u myotherlambda --delete myoldlambda

Or specify your functions in a YAML file (let’s call it sync.yaml).

hello:
    handler: mymodule.hello
    role: arn:aws:iam::xxxxxxxxxxxx:role/myrole
# myotherlambda:
#     handler: myothermodule.myotherhandler
#     role: arn:aws:iam::xxxxxxxxxxxx:role/myrole

When syncing from a file, awslambda will update existing functions and create the others automatically.

awslambda . mybucket --sync sync.yaml

To add dependencies, use your pip requirements file.

awslambda . mybucket -s sync.yaml --requirements requirements.txt

Note that compiled dependencies awslambda downloads on your local machine might not work on the AWS servers. Pure Python libraries should always work. For others, it could be helpful to run awslambda itself in a Lambda function. A process knows as awslambdaception.

A template greeting page

Let’s use the features introduced above to create a greeting page. We will use the Jinja2 templating engine. Edit mymodule.py,

from jinja2 import Template

template = Template('''
<html>
  <body>
    <h1>Hello, {{ parameters.name }}!</h1>
    <p>{{ parameters.message }}</p>
  </body>
</html>
''')


def hello(event, context):
    return {
        'statusCode': 200,
        'headers': {'Content-Type': 'text/HTML'},
        'body': template.render(parameters=event['queryStringParameters'])}

and create a simple requirements.txt.

Jinja2

Deploy,

awslambda . mybucket -s sync.yaml -r requirements.txt

then open the function in your AWS console. Go to Triggers and add an API Gateway trigger. Set security to Open for now. Open the URL of the created trigger in your browser. You should see “Hello, !”. To customize the page append e.g.

?name=Commander Shepard&message=You've received a new message at your private terminal.

to the URL and enjoy your serverless, templated webpage!

Usage

Usage: awslambda [OPTIONS] SOURCE_DIR S3_BUCKET

  Deploy Python code to AWS lambda.

  Zips the contents of the source directory together with optional pip
  requirements. The archive is temporarily uploaded to an S3 bucket and used
  to create or update lambda functions.

  Reference handlers from your source directory like you would in any Python
  module-tree (e.g. mymodule.myhandler, mymodule.mysubmodule.myhandler,
  etc.).

  Roles are ARNs like "arn:aws:iam::xxxxxxxxxxxx:role/myrole"

  YAML file entries for the sync option map function names to handlers and
  roles:

      myLambda:
          handler: mymodule.myhandler
          role: arn:aws:iam::xxxxxxxxxxxx:role/myrole

Options:
  -r, --requirements PATH         pip compatible requirements file. Will be
                                  included in the archive.
  -c, --create NAME HANDLER ROLE  Create a new lambda function. Example:
                                  --create myLambda mymodule.myhandler myrole
  -u, --update NAME               Update a lambda function.
  -d, --delete NAME               Delete a lambda function.
  -s, --sync FILENAME             Keep lambdas defined in YAML file in sync
                                  with deployed lambdas.
  --help                          Show this message and exit.
Release History

Release History

1.0.6

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
awslambda-1.0.6-py2-none-any.whl (9.8 kB) Copy SHA256 Checksum SHA256 py2 Wheel Dec 4, 2016
awslambda-1.0.6.tar.gz (6.5 kB) Copy SHA256 Checksum SHA256 Source Dec 4, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting