Skip to content

Connections ​

Bruin has various commands to handle connections via its CLI.

Bruin CLI offers convenience methods to manage connections when using .bruin.yml as our secrets backend.

An explicit --config-file path (also supported through BRUIN_CONFIG_FILE) must exist unless configuration is supplied through BRUIN_CONFIG_FILE_CONTENT; a missing file returns an error. Without a specified path, the default .bruin.yml is still created when needed.

List Connections ​

To list all the connections in the .bruin.yml file, run the following command:

bash
bruin connections list

The output will look like this. FILLED FIELDS lists the names of the fields that are set on each connection, never their values:

plaintext
Environment: default
+---------+-----------+------------------------+
| TYPE    | NAME      | FILLED FIELDS          |
+---------+-----------+------------------------+
| generic | MY_SECRET | value                  |
| gorgias | my_conn   | api_key, domain, email |
+---------+-----------+------------------------+

Environment: someother
+---------+-----------+---------------+
| TYPE    | NAME      | FILLED FIELDS |
+---------+-----------+---------------+
| generic | MY_SECRET | value         |
+---------+-----------+---------------+

Flags ​

FlagTypeDefaultDescription
--output, -ostrplainOutput format: plain or json.
--environment, -e, --envstr-The environment to list connections for.
--config-filestr-The path to the .bruin.yml file.

Add Connection ​

Interactive mode ​

When run without flags in a terminal, bruin connections add launches an interactive wizard that walks you through:

  1. Selecting an environment
  2. Entering a connection name
  3. Choosing a connection type (with search/filter)
  4. Filling in the credential fields for that type
bash
bruin connections add

Flag-based mode ​

You can also provide all parameters via flags for scripting and CI/CD usage:

bash
bruin connections add --env someother --type generic --name MY_SECRET --credentials '{"value": "someothersecret"}'

This will add the connection to the .bruin.yml file and the connection will be available in the given environment.

The parameter after --credentials is the value of the connection in JSON format, as you would write it in the .bruin.yml file. For further reference, you can check the Connections documentation.

INFO

When using flags, all four of --env, --name, --type, and --credentials must be provided together. Providing only some of them will result in an error.

Flags ​

FlagTypeDefaultDescription
--environment, -e, --envstr-The name of the environment to add the connection to.
--namestr-The name of the connection.
--typestr-The type of the connection.
--credentialsstr-The JSON object containing the credentials.
--config-filestr-The path to the .bruin.yml file.

Example: a GCP connection ​

bash
bruin connections add \
    --env default \
    --type google_cloud_platform \
    --name MY_GCP_CONNECTION \
    --credentials '{"project_id": "my-gcp-project", "service_account_file": "path/to/service/account/file.json"}'

Example: a generic secret ​

bash
bruin connections add \
    --env staging \
    --type generic \
    --name MY_SECRET \
    --credentials '{"value": "secret-password"}'

Delete Connection ​

To delete a connection from a specific environment, use the following command:

bash
bruin connections delete --env staging --name MY_SECRET

You can define a different path for the repo with an extra argument if you'd like:

bash
bruin connections delete --env staging --name MY_SECRET <path-to-repo>

Flags ​

FlagTypeDefaultDescription
--environment, -e, --envstr-The environment to delete the connection from.
--name, -nstr-The name of the connection to delete.
--output, -ostrplainOutput format: plain or json.
--config-filestr-The path to the .bruin.yml file.

Example ​

Delete a connection named "test-connection" from the "staging" environment:

bash
bruin connections delete -e staging -n test-connection -o json

Test Connection ​

To test if a connection is valid, you can use the test command. This command runs a simple validation check for the connection.

bash
bruin connections test --name <connection-name> [--env <environment>]

If no environment flag (--env) is provided, the default environment from our .bruin.yml will be used.

Flags ​

FlagTypeDefaultDescription
--name, -nstr-The name of the connection to test.
--environment, -e, --envstr-The environment to use.
--output, -ostrplainOutput format: plain or json.
--config-filestr-The path to the .bruin.yml file.

Examples ​

Test a connection in the default environment:

bash
bruin connections test --name my-bigquery-conn

Test a connection in a specific environment:

bash
bruin connections test --name my-snowflake-conn --env production

You can also get the output in JSON format:

bash
bruin connections test --name my-postgres-conn --env staging --output json