serverless-builder
Python interface to easily generate serverless.yml file.
To read more about features, visit 📜 our documentation.
Installation
pip install serverless-builder
Features
- plugin management with autoconfiguration
- function factory with some best practice hints
- autoconfiguration of some provider specific features like AWS X-Ray
- easy resource manipulation with troposphere lib (but if you want you can use old good dict)
- easier IAM management with predefined permission sets
- built-in support for any serverless attributes
- integration with aws lambda powertools
Example of use
from serverless.aws.functions.event_bridge import RetryPolicy
from serverless.aws.functions.http import HTTPFunction
from serverless import Service
from serverless.provider import AWSProvider
from serverless.aws.features import XRay
from serverless.aws.iam.dynamodb import DynamoDBReader
from serverless.plugins import ComposedVars, PythonRequirements, Prune
from troposphere.dynamodb import Table, AttributeDefinition, KeySchema
service = Service(
"service-name",
"some dummy service",
AWSProvider()
)
service.plugins.add(ComposedVars())
service.plugins.add(Prune())
service.plugins.add(PythonRequirements())
table = Table(
"TestTable",
BillingMode="PAY_PER_REQUEST",
AttributeDefinitions=[
AttributeDefinition(AttributeName="name", AttributeType="S")
],
KeySchema=[KeySchema(AttributeName="name", KeyType="HASH")]
)
service.enable(XRay())
service.provider.iam.apply(DynamoDBReader(table))
service.builder.function.generic("test", "description")
service.builder.function.http("test", "description", "/", HTTPFunction.POST)
# Multiple events with different paths and/or methods can be set up for the same handler
# This will add the same handler to all of these: POST /, POST /alias, PUT /, PUT /alias
service.builder.function.http("test", "description", ["/", "/alias"], ["POST", "PUT"], handler="shared.handler")
# Context with pre-defined setup
with service.preset(
layers=[{"Ref": "PythonRequirementsLambdaLayer"}],
handler="test.handlers.custom_handler.handle"
) as p:
p.http_get("test-list", "List all tests", "/")
p.http_get("test-get", "Get one test", "/{test_id}")
event_bridge_function = service.builder.function.event_bridge(
"event_bridge_function",
"sample event bridge function",
"epsy",
{"source": ["saas.external"]},
)
event_bridge_function.use_delivery_dlq(RetryPolicy(5, 300))
event_bridge_function.use_async_dlq()
service.resources.add(table)
service.render()
New version release process
-
Update the version in pyproject.toml
# increase the version number as per SemVer standards version = "2.13.17" -
Once ready to publish, create a new github release
- its a good practice to match the tag with the version number as in pyproject.toml
- Select
set as latest releasecheckbox - Click
Publish Releasebutton.
-
Once published, it will trigger the
releasegh wf and publish the latest package to PyPi.
Metadata
Release files for serverless-builder 2.19.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| serverless_builder-2.19.6.tar.gz | 33.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| serverless_builder-2.19.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 92.1 kB
Release files / serverless_builder-2.19.6.tar.gz
| Download URL | serverless_builder-2.19.6.tar.gz |
|---|---|
| Size | 33.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd5d5c7abc5d45ab6033928ae27f45f2d652a3b173775807b15649a60ff4ec0c
|
|
BLAKE2b-256 checksum How to use checksums |
18187b7442cf2c18b3c36ff3c561eda48aeac44350e1dea259dcdf55fd872b7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Release files / serverless_builder-2.19.6-py3-none-any.whl
| Download URL | serverless_builder-2.19.6-py3-none-any.whl |
|---|---|
| Size | 58.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2fd35424ad6419454b527e2d03a0b300acfdd6895731b3d67ddf75455dc28f0b
|
|
BLAKE2b-256 checksum How to use checksums |
b7df079a6f4c4f23ecd5008acbfa31b27a8af108d7b6971b93c98ee3dc3dd4fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Security for serverless-builder 2.19.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.