cloudsoft.io

Effectors and Workflow

Effectors are operations defined on your resources and made available at runtime. These are defined with effector blocks on your resources, with the following basic structure:

effector "some_operation" {
  steps = [
    "return ${self.name}"
  ]
}

Steps are written in AMP’s simple workflow language, and can call to web endpoints or containers, shell scripts or ansible playbooks. They can also interact with and change the Maeztro model, for instance to invoke other effectors, set sensors or create new resources.

As shown above, you can reference expressions just as is done in Terraform. These are evaluated when the expression is run, and allow your operations to make use of context on the entity.

Parameters

Parameters can be defined for effectors to allow their behavior to be customized at runtime, This is done with parameter "NAME" blocks inside the effector block. The parameter name can then be referenced in workflow.
For example:

effector "makeUpperCase" {
  parameter "message" {
    default = "Hello"
  }
  steps = [
    "return ${upper(message)}}"
  ]
}

Other Effector Options

Other optional attributes and blocks which can be set on an effector block include:

  • on-error: this is a step or list of steps to run if the workflow has an error
  • lock: a mutex lock name (or map of an entity address and lock name to use a shared lock on another entity) which will have to be acquired by the workflow before running, and held while running, preventing any other workflow that needs the lock from running concurrently
  • timeout: the workflow will be interrupted and fail if it does not complete within this time
  • condition: the effector will be prevented from running if the indicated condition is not met

Full details on effectors are available in the adjuncts page.