No project description provided
Project description
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, whereN
can be 0 or greaterM
SNS outputs, whereM
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 intoInputs
(a list of dictionaries): creates an SQS trigger that is subscribed to the defined SNS topicOutputs
(a list of dictionaries): creates an SNS topic that can be referenced in theos.environ
dictionaryNode
: 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
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
File details
Details for the file fabnodes-0.0.5.tar.gz
.
File metadata
- Download URL: fabnodes-0.0.5.tar.gz
- Upload date:
- Size: 22.8 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f892b9a4643078301431ba057061afeb01eeab40694821c072db911bf64de35 |
|
MD5 | a2c230fa64cd5557e7603cf0eb9d9c90 |
|
BLAKE2b-256 | a36ca7379cdea473362db698f4098981cf536a64af322b317e9307d7a9b38d4f |