Skip to main content

LBR Context Manager

The best tool for AWS lambda-backed custom resources since sliced cheese!

How is it used

I'm glad you asked!

First pip install lbr-context, then in your custom resource handler:

from lbr_context import CfnContext


def handler(event=None, context=None):
    event = event or {}
    request_type = event['RequestType'].upper()
    with CfnContext(event, context) as cfn:
        if 'CREATE' in request_type:
            # handle a create here
            pass
        elif 'UPDATE' in request_type:
            # handle an update here
            pass
        elif 'DELETE' in request_type:
            # handle a delete here
            pass

So what makes this better

One of the big pains experienced when writing custom resources is getting it wrong, because this can cause your resource to be in an IN_PROGRESS state for a long time.

This context manager addresses that, and will catch any uncaught exception. When it catches an exception, it sends the FAILED request to the event's endpoint, so CloudFormation knows your custom resource failed to create/update/delete.

On top of that, this context manager sets a timer for when the lambda is about to run out of time, so that it will make sure the FAILED request is sent, even if your lambda's timeout is improperly configured.

Metadata

Release files for lbr-context 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lbr-context 0.2.1
File Size Uploaded Provenance Actions
lbr_context-0.2.1.tar.gz 4.1 kB Without provenance Details for lbr_context-0.2.1.tar.gz

Release files / lbr_context-0.2.1.tar.gz

Download URL lbr_context-0.2.1.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f7a7b75241f83279d88b531178480370983dde9baee59cb04b03a60f49499624
BLAKE2b-256 checksum
How to use checksums
a2fb862839e9341e219bba60b8cca01eabc56f6ca4ed4ec1721f7c5b37ac5724
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.10

Security for lbr-context 0.2.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page