Skip to main content

fabnodes

fabnodes is a Python CLI application that creates prefabricated lambda nodes. Using these 'node prefabs' one can create complicated distributed processes.

Requirements

The python requirements are stored in requirements.txt. fabnodes currently uses cfndsl to generate CloudFormation JSON files. The instructions to install cfndsl is available through the provided link.

Basic setup

Install the requirements:

$ pip install -r requirements.txt

Run the application:

$ python -m fabnodes --help

To run the tests (todo):

    $ pytest

Prefab: Basic Node

The Basic Node (samples/basic_node/node.py) will create the most basic node with the following features:

  • N SQS inputs, where N can be 0 or greater
  • M SNS outputs, where M can be 0 or greater
  • 1 Lambda Function that triggers on any input, and can write to any output

Below is a masterpiece that will attempt to illustrate:

==========================================================================



                                    |----------- Basic Node ----------|

.. -> SNS(SomeNode.alpha) ----\                          /--> SNS(output) -> ..
                               ---> SQS(input) -> Lambda
.. -> SNS(random topic)    ---/                          \--> (something)



==========================================================================

To create this node your cwd needs to be the same as node.py:

fabnodes create node.py --account-arn XXXXXXXXXXXX

At the moment the account-arn needs to be passed in because security.

This will make the calls required to CloudFormation that will create the above infrastructure.

Use-cases:

The basic node has the following use-cases:

  • The Source Node: A node that reads from an input source (that isn't another prefab node) that then can forward to many through a topic (0:M node)
  • The Router: A node that takes an input and can 'farm' it out to specifically made workers (other prefab nodes) through named topics (1:M node)
  • The Worker: A node that listens on a topic, performs a specific task, then creates output (1:1 node)
  • The Ingest: A node that listens to many topics, consumes data, and then produces output for a non-prefab node (M:0 node)

The Sample: node.py

Below is an explanation of the provided sample.

@fablib.Distribution('jlh-dev-lambda-functions')
@fablib.Inputs([
    {'name': 'Router', 'source': 'snsRouterTopicId'}])
@fablib.Outputs([
    {'name': 'Alpha'}])
@fablib.Node('BasicNode', 'comRoaetFabnodeSample', 'Basic Node')
def lambda_handler(events, context):
    client = boto3.client('sns')
    sns_target_arn = os.environ['Alpha']
    body_content = json.dumps(events)
    response = client.publish(
        TargetArn=sns_target_arn,
        Message=json.dumps({'default': body_content}),
        MessageStructure='json'
    )
    print(response)
  • The lambda_handler method is defined exactly as a normal lambda handler
  • The decorators:
    • Distribution: defines the S3 bucket to put the code into
    • Inputs (a list of dictionaries): creates an SQS trigger that is subscribed to the defined SNS topic
    • Outputs (a list of dictionaries): creates an SNS topic that can be referenced in the os.environ dictionary
    • Node: defines the name of the lambda function, the name of the stack, and the description of the stack
      • The name of the stack can be used as a reference in other prefabs to create the input/output connections

References

fabnodes is a Python CLI application generated from https://github.com/roaet/rorochip-cookies

Metadata

Release files for fabnodes 0.0.7

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

Source distribution (sdist)

Source distribution for fabnodes 0.0.7
File Size Uploaded Provenance
fabnodes-0.0.7.tar.gz 22.8 kB Without provenance Details

Release files / fabnodes-0.0.7.tar.gz

Download URL fabnodes-0.0.7.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cc6f283c3a67edd84cd57e52652cb75e752f9b5942f215444160d254e0370afd
BLAKE2b-256 checksum
How to use checksums
9a3e0f24272705c2f163db4f716518be7d09a77aa5da241aa9dea4e10bb0d893
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

Security for fabnodes 0.0.7

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.

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