Skip to main content

Python interface to easily generate `serverless.yml`.

Project description


PyPI Python License

Python interface to easily generate serverless.yml file.

To read more about features, visit 📜 our documentation.


pip install serverless-builder


  • 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 import RetryPolicy
from import HTTPFunction
from serverless import Service
from serverless.provider import AWSProvider
from import XRay
from import DynamoDBReader
from serverless.plugins import ComposedVars, PythonRequirements, Prune

from troposphere.dynamodb import Table, AttributeDefinition, KeySchema

service = Service(
    "some dummy service",

table = Table(
        AttributeDefinition(AttributeName="name", AttributeType="S")
    KeySchema=[KeySchema(AttributeName="name", KeyType="HASH")]


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"}],
) 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(
    "sample event bridge function",
    {"source": ["saas.external"]},

event_bridge_function.use_delivery_dlq(RetryPolicy(5, 300))



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 release checkbox
    • Click Publish Release button.
  • Once published, it will trigger the release gh wf and publish the latest package to PyPi.

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

serverless_builder-2.16.6.tar.gz (29.0 kB view hashes)

Uploaded Source

Built Distribution

serverless_builder-2.16.6-py3-none-any.whl (51.0 kB view hashes)

Uploaded Python 3

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