aws / aws/chalice

[proposal] Rest API with multiple lambda functions

Open
#1,308 5 comments 48 reactions 0 assignees View on GitHub
proposals
Dominant language
Python
Stars
11.1k
Forks
1k
Avg merge
1d 22h
Merged PRs (30d)
2

Description

## Overview ##

The current state of the framework deploy the entire project into a single lambda function instance. But for larger projects this can be a problem for several reasons:
- Monitor individual lambda routes integration (number of invocations, errors, etc).
- Controlling individually the lambda functions (permissions, throttling, etc).
- For optimize the lambda function deployment package (.zip).
- If there is an error with one function, the other ones will not be affected.

## Register Handler class ##

The routes will be registered from each handler that will be implemented separately. Below is an example of the hello handler:

Example of usage:
app.py
```python
from chalice import Chalice

app = Chalice(app_name="helloworld")

app.registrate_route(
name='hello_world',
path='/helloworld',
handler_class=HelloHandler,
)
```
hello_world.py
```python
from chalice import LambdaHandler

class HelloWorldHandler(LambdaHandler):

def get(self):
return {"hello": "world"}
```

To make packaging possible, the project directory must be structured in a specific way.
as follows:
```

├── helloworld
│ ├── functionlib # function specific modules
│ │ ├── __init__.py
│ │ └── utils.py
│ ├── __init__.py
│ └── helloworld.py
├── chalicelib # project shared modules
│ ├── __init__.py
│ └── generics.py
├── app.py
├── requirements.txt
└── etc ...
```

Contributor guide

Open the contributing guide

Research direction

Start with the app.py registration example and the proposed hello_world.py handler, then compare them with Chalice's current deployment and packaging behavior. Review the proposed project layout, including functionlib, chalicelib, and requirements.txt. Done would mean independently deployable Lambda functions with routes registered through separate handlers.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
api, backend, cloud
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.