Connectors
About
Connectors are the Cloudomation functions that allow your flow scripts to interact with the outside world - anything and everything outside of the Cloudomation platform. Whenever you want to issue a command to a program, run a script on a remote system, or get query a database - all that is performed through connectors.
There are different connector types, each for a particular type of endpoint / protocol.
Connectors are called through the Cloudomation function this.connect(). Each call creates a separate execution of type "connection", with its own inputs and outputs.
For example, you can call a REST API using the Cloudomation REST connector type:
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution):
inputs = {
'url': 'https://httpbin.org/post',
'method': 'post',
'data': 'payload',
}
child_execution = this.connect(connector_type='REST', **inputs, run=False)
child_execution.run_async()
# do other stuff
child_execution.wait()
outputs = child_execution.get('output_value')
this.log(outputs)
return this.success('all done')
Simple example
Create a connector for the GIT connector type and call it "repository". Enter the following into the value field:
ref: develop
command: metadata
repository_url: 'https://example.com/path/to/repo.git'
The configuration must be a valid YAML document: yaml.org/spec It is also possible to enter a JSON config, since YAML is a superset of JSON.
Next, create a new flow to use the connector and call it "connector-test". Use the following script:
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution):
metadata = this.connect('repository').get('output_value')
this.log(metadata['date_str'])
return this.success('all done')
Override inputs
You can override inputs which are stored in the connector by specifying different values when using the connector. Let's modify the "connector-test" flow from before to read information for a different ref
:
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution):
metadata = this.connect('repository', ref='v2').get('output_value')
this.log(metadata['date_str'])
return this.success('all done')
Attach Vault Secrets
To be able to attach secrets to a connector, a working vault integration must be configured beforehand.
Please refer to Vault Integration for details.
Order of Input Application
Inputs for a connection execution can be specified in different places. Inputs from all places are merged into one combined input set before being used by the connector. Inputs are applied in the following order:
- Value of the connector
- Vault secrets associated with the connector
- Inputs specified in the flow script
Inputs which are applied later can override keys of inputs which were applied before. If, for example, the connector specifies a key port
and the vault secret also contains a key port
, the value of the vault secret will be used.