Skip to main content

It's abstraction on top of AWS CDK, that helps in building serverless web applications.

Project description

Viburnum

Viburum - it's a small framework built on top of AWS CDK to simplify development and deploying AWS Serverless web applications.

Installing

Package consist of two pats primitives that help to describe your handlers and resources and deployer that will convert primitives into CloudFormation using CDK.

Installing only primitives

pip install viburnum

Installing with deployer

pip install "viburnum[deployer]"

Lambda function will require only primitives to work correctly. That's why it's recommended to add viburnum into requirements.txt and viburnum[deployer] into requirements-dev.txt

Project structure

Each Lambda function handler is represented as folder with handler.py inside and other files if required.

Example handler.py:

from viburnum.application import Request, Response, route

@route("/tests/{id}", methods=["GET"])
def get_test(request: Request, test_queue):
    print(f"Get test: {request.path_params.get('id')}")
    return Response(200, {})

In the root folder you need to have app.py file with Application, this file used by deployer and CDK to determine all related resources.

Example app.py

import aws_cdk as cdk
from viburnum.deployer.builders import AppConstruct
from viburnum.application import Application, Sqs

from functions.api.get_test.handler import get_test

app = Application("TestApp")
# Handlers
app.add_handler(get_test)

context = cdk.App()
AppConstruct(context, app)
context.synth()

All logic that shared across all lambdas, must be placed inside shared folder, and it will plugged into Lambda as a Layer.

Recommended structure

├── functions
│   ├── __init__.py
│   ├── api
│   │   ├── __init__.py
│   │   ├── some_api
│   │   │    ├── __init__.py
│   │   │    ├── handler.py
│   │   │    └── ...
│   │   │
│   │   └── ...
│   │   
│   ├── jobs
│   │   ├── __init__.py
│   │   ├── some_job
│   │   │    ├── __init__.py
│   │   │    ├── handler.py
│   │   │    └── ...
│   │   │
│   │   └── ...
│   │   
│   └── workers
│       ├── __init__.py
│       ├── some_job
│       │    ├── __init__.py
│       │    ├── handler.py
│       │    └── ...
│       │
│       └── ...
│      
├── shared
│   ├── __init__.py
│   └── ...
│
├── app.py
├── requirements-dev.txt
└── requirements.txt

CLI tool

Viburnum deployer include CLI tool that helps initializing project and creating a new handlers. After initializing project folder with cdk init app --language python you can call virburnum init, that command will change some files so Virburnum can work correctly. There is command for creating new handlers virburnum add [HANDLER_TYPE] that will create a handler.

Supported HANDLER_TYPE:

  • api
  • worker
  • job

Example app

Simple example app

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

viburnum-0.1.6.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

viburnum-0.1.6-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file viburnum-0.1.6.tar.gz.

File metadata

  • Download URL: viburnum-0.1.6.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.10.8 Darwin/22.1.0

File hashes

Hashes for viburnum-0.1.6.tar.gz
Algorithm Hash digest
SHA256 f5d7890c0c5880e540750f7a80eb8f4742a6bee1773b47ab31d7a1b9eb01beb4
MD5 56a71d79679d232e9f4a9578e228b262
BLAKE2b-256 5cfe7464b8c15b756f23f79d333ff37158906b0decc54ec488d00a95ccc5fa3f

See more details on using hashes here.

File details

Details for the file viburnum-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: viburnum-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.10.8 Darwin/22.1.0

File hashes

Hashes for viburnum-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4e28edec6370de9f9b8a992388c323f3edadc4ab320a81d81865b0aede6e4965
MD5 922ff6bc98f25b9eeb3251a2f3dcacb6
BLAKE2b-256 e1b76bfae88165e8b502b65a340de6ab8f6dae753c38c5822193a37e4fe4abdf

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