serverless-builder


Nameserverless-builder JSON
Version 2.16.8 PyPI version JSON
download
home_pagehttps://epsylabs.github.io/serverless-builder/
SummaryPython interface to easily generate `serverless.yml`.
upload_time2024-07-01 11:01:37
maintainerNone
docs_urlNone
authorEpsy
requires_python<4.0,>=3.8
licenseMIT
keywords library serverless
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h2 align="center">serverless-builder</h2>
<p align="center">
<a href="https://pypi.org/project/serverless-builder/"><img alt="PyPI" src="https://img.shields.io/pypi/v/serverless-builder"></a>
<a href="https://pypi.org/project/serverless-builder/"><img alt="Python" src="https://img.shields.io/pypi/pyversions/serverless-builder.svg"></a>
<a href="https://github.com/epsylabs/serverless-builder/blob/master/LICENSE"><img alt="License" src="https://img.shields.io/pypi/l/serverless-builder.svg"></a>
</p>

Python interface to easily generate [serverless.yml](https://www.serverless.com/) file.

To read more about features, visit [📜 our documentation](https://epsylabs.github.io/serverless-builder/).

## Installation
```shell
pip install serverless-builder
```

## Features
* [plugin management](https://epsylabs.github.io/serverless-builder/plugins/) with autoconfiguration
* [function factory](https://epsylabs.github.io/serverless-builder/usage/#lambda-functions) with some best practice hints
* autoconfiguration of some provider specific features like AWS X-Ray
* easy resource manipulation with [troposphere lib](https://github.com/cloudtools/troposphere) (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](https://awslabs.github.io/aws-lambda-powertools-python/latest/)

## Example of use

```python
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](https://github.com/epsylabs/serverless-builder/releases)
    - 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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://epsylabs.github.io/serverless-builder/",
    "name": "serverless-builder",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "library, serverless",
    "author": "Epsy",
    "author_email": "engineering@epsyhealth.com",
    "download_url": "https://files.pythonhosted.org/packages/87/f7/05427cc92405e3078f30fe9bfc807f8d8dd33b2265a109cd1cd7ac08f87e/serverless_builder-2.16.8.tar.gz",
    "platform": null,
    "description": "<h2 align=\"center\">serverless-builder</h2>\n<p align=\"center\">\n<a href=\"https://pypi.org/project/serverless-builder/\"><img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/serverless-builder\"></a>\n<a href=\"https://pypi.org/project/serverless-builder/\"><img alt=\"Python\" src=\"https://img.shields.io/pypi/pyversions/serverless-builder.svg\"></a>\n<a href=\"https://github.com/epsylabs/serverless-builder/blob/master/LICENSE\"><img alt=\"License\" src=\"https://img.shields.io/pypi/l/serverless-builder.svg\"></a>\n</p>\n\nPython interface to easily generate [serverless.yml](https://www.serverless.com/) file.\n\nTo read more about features, visit [\ud83d\udcdc our documentation](https://epsylabs.github.io/serverless-builder/).\n\n## Installation\n```shell\npip install serverless-builder\n```\n\n## Features\n* [plugin management](https://epsylabs.github.io/serverless-builder/plugins/) with autoconfiguration\n* [function factory](https://epsylabs.github.io/serverless-builder/usage/#lambda-functions) with some best practice hints\n* autoconfiguration of some provider specific features like AWS X-Ray\n* easy resource manipulation with [troposphere lib](https://github.com/cloudtools/troposphere) (but if you want you can use old good dict)\n* easier IAM management with predefined permission sets\n* built-in support for any serverless attributes\n* integration with [aws lambda powertools](https://awslabs.github.io/aws-lambda-powertools-python/latest/)\n\n## Example of use\n\n```python\nfrom serverless.aws.functions.event_bridge import RetryPolicy\nfrom serverless.aws.functions.http import HTTPFunction\nfrom serverless import Service\nfrom serverless.provider import AWSProvider\nfrom serverless.aws.features import XRay\nfrom serverless.aws.iam.dynamodb import DynamoDBReader\nfrom serverless.plugins import ComposedVars, PythonRequirements, Prune\n\nfrom troposphere.dynamodb import Table, AttributeDefinition, KeySchema\n\nservice = Service(\n    \"service-name\",\n    \"some dummy service\",\n    AWSProvider()\n)\nservice.plugins.add(ComposedVars())\nservice.plugins.add(Prune())\nservice.plugins.add(PythonRequirements())\n\ntable = Table(\n    \"TestTable\",\n    BillingMode=\"PAY_PER_REQUEST\",\n    AttributeDefinitions=[\n        AttributeDefinition(AttributeName=\"name\", AttributeType=\"S\")\n    ],\n    KeySchema=[KeySchema(AttributeName=\"name\", KeyType=\"HASH\")]\n)\n\nservice.enable(XRay())\nservice.provider.iam.apply(DynamoDBReader(table))\n\nservice.builder.function.generic(\"test\", \"description\")\nservice.builder.function.http(\"test\", \"description\", \"/\", HTTPFunction.POST)\n\n# Multiple events with different paths and/or methods can be set up for the same handler\n# This will add the same handler to all of these: POST /, POST /alias, PUT /, PUT /alias\nservice.builder.function.http(\"test\", \"description\", [\"/\", \"/alias\"], [\"POST\", \"PUT\"], handler=\"shared.handler\")\n\n# Context with pre-defined setup\nwith service.preset(\n    layers=[{\"Ref\": \"PythonRequirementsLambdaLayer\"}],\n    handler=\"test.handlers.custom_handler.handle\"\n) as p:\n    p.http_get(\"test-list\", \"List all tests\", \"/\")\n    p.http_get(\"test-get\", \"Get one test\", \"/{test_id}\")\n\nevent_bridge_function = service.builder.function.event_bridge(\n    \"event_bridge_function\",\n    \"sample event bridge function\",\n    \"epsy\",\n    {\"source\": [\"saas.external\"]},\n)\n\nevent_bridge_function.use_delivery_dlq(RetryPolicy(5, 300))\nevent_bridge_function.use_async_dlq()\n\nservice.resources.add(table)\n\nservice.render()\n```\n\n# New version release process\n\n- Update the version in pyproject.toml \n\n    ```\n    # increase the version number as per SemVer standards\n    version = \"2.13.17\"\n    ```\n\n- Once ready to publish, create a new [github release](https://github.com/epsylabs/serverless-builder/releases)\n    - its a good practice to match the tag with the version number as in pyproject.toml\n    - Select `set as latest release` checkbox\n    - Click `Publish Release` button.\n\n- Once published, it will trigger the `release` gh wf and publish the latest package to PyPi.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python interface to easily generate `serverless.yml`.",
    "version": "2.16.8",
    "project_urls": {
        "Homepage": "https://epsylabs.github.io/serverless-builder/",
        "Repository": "https://github.com/epsylabs/serverless-builder"
    },
    "split_keywords": [
        "library",
        " serverless"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "64110eb808e817575b9800cff631117b00455088760b6720e8dd1da04c08af32",
                "md5": "bc9985d2e037e218712a4eebf724cd59",
                "sha256": "675cd660f1229bf7b847453c7b47f0a04820bd753e249c57eb4766197164c65e"
            },
            "downloads": -1,
            "filename": "serverless_builder-2.16.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bc9985d2e037e218712a4eebf724cd59",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 51046,
            "upload_time": "2024-07-01T11:01:35",
            "upload_time_iso_8601": "2024-07-01T11:01:35.663487Z",
            "url": "https://files.pythonhosted.org/packages/64/11/0eb808e817575b9800cff631117b00455088760b6720e8dd1da04c08af32/serverless_builder-2.16.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "87f705427cc92405e3078f30fe9bfc807f8d8dd33b2265a109cd1cd7ac08f87e",
                "md5": "4c94b4d8ea8bae6bcb13bb38e01ddf95",
                "sha256": "9b66920f9bda106386935941b554a7643b11e5df2c91f3971e319fce1e512257"
            },
            "downloads": -1,
            "filename": "serverless_builder-2.16.8.tar.gz",
            "has_sig": false,
            "md5_digest": "4c94b4d8ea8bae6bcb13bb38e01ddf95",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 29032,
            "upload_time": "2024-07-01T11:01:37",
            "upload_time_iso_8601": "2024-07-01T11:01:37.723118Z",
            "url": "https://files.pythonhosted.org/packages/87/f7/05427cc92405e3078f30fe9bfc807f8d8dd33b2265a109cd1cd7ac08f87e/serverless_builder-2.16.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-01 11:01:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "epsylabs",
    "github_project": "serverless-builder",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "serverless-builder"
}
        
Elapsed time: 0.28444s