Cohesion is a source to source compiler that accepts a Python program and outputs a Step Functions workflow plus a set of Lambda functions. Cohesion supports a subset of Python, and adds a small amount of syntax.
It's aimed primarily as a way to make it easier to produce new serverless systems; not as a way to transparently transform large existing codebases.
Alright, let's make our first workflow! Let's start with a simple example: a one-step "workflow" that calls one AWS Lambda function.
Without Cohesion, you can write this as a JSON document, using the AWS Step Functions Language.
Cohesion allows you to write it in Python instead -- and then use compile your Python code into the Step Functions JSON.
Our workflow is defined in workflow.py
. It calls a function called hello
, which is defined in hello.py
.
You can call the Lambda function using the syntax shown. The cohesion compiler generates an ARN from this using your region and account ID, which are in your config file.
Note that cohesion.Lambda
is additional syntax, not a Python module. You can't take the address of it, or in general do anything dynamic with it -- the cohesion compiler uses this syntax to find the edges in the workflow graph.