OB2 Logo

Opsbeacon

Lambda Workflow

The Lambda Workflow feature allows you to organize and execute workflows using Lambda functions, in addition to our native workflow capabilities. Each Lambda workflow comes with a default handler function:

def lambda_handler(ob, event):

The ob parameter provides access to methods in the Opsbeacon library. For more details, refer to the official Opsbeacon documentation: OpsBeacon Library


Usage Examples

Running Commands with Connections

You can execute commands using predefined connections as follows:

def lambda_handler(ob, event):
    result = ob.run(command="todos", connection="jsonplaceholder", args="")
    print(result)

Listing Available Commands

To retrieve a list of available commands:

def lambda_handler(ob, event):
    commands = ob.commands()
    print(commands)

Custom Functions and Script Integration

In addition to using Opsbeacon methods, you can define custom functions and scripts to extend the workflow's capabilities. This flexibility allows you to merge pre-defined Opsbeacon methods with your own Python functions, enabling highly customizable task definitions.

Example:

def custom_function():
    return "This is a custom function."

def lambda_handler(ob, event):
    print(custom_function())
    result = ob.run(command="status", connection="server", args="--verbose")
    print(result)

Conclusion

With the Lambda Workflow feature, you can create flexible and powerful workflows by combining Opsbeacon methods with your own custom logic. This enables more control and customization over your automation tasks.

Previous
Native Workflow