Running Flow Scripts Remotely
You can run a flow script from your local machine by using a helper script:
flow-runner.bash:
#!/usr/bin/env bashecho "Running flow..."DIR=$(dirname $0)TOKEN_FILE="${DIR}/token"TOKEN=$(cat "${TOKEN_FILE}")if [ -z "${TOKEN}" ]; then${DIR}/auth.bashfiFLOW=$1if [ -z "${FLOW}" ]; thenecho "missing parameter " 1>&2exit 1fiif [ ! -f "${FLOW}" ]; thenecho "flow ${FLOW} does not exist" 1>&2exit 1fiecho "Flow: ${FLOW}"NAME=$(basename "${FLOW}")SCRIPT=$(cat "${FLOW}" | base64 -w0)EXECUTION="{\"script\":\"${SCRIPT}\",\"name\":\"${NAME}\"}"curl -H "Authorization: $TOKEN" -d "${EXECUTION}" https://<my-workspace-name>.cloudomation.com/api/latest/executionecho ""
This helper script requires auth.bash
to be in the same directory. Please find more information in the article about Authentication.
You can execute the helper script and pass the path to a local flow script as first parameter:
bash:
$ ./flow-runner.bash hello.pyRunning flow...Flow: hello.py{"id": 1234}
You can also use the helper script as shebang in your script and directly execute it:
hello.py:
#!/path/to/your/flow-runner.bashimport flow_apidef handler(system: flow_api.System, this: flow_api.Execution):return this.success('hello world')
bash:
$ chmod +x hello.py$ ./hello.pyRunning flow...Flow: ./hello.py{"id": 1235}