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.
List Connections
To list all the connections in the .bruin.yml file, run the following command:
bruin connections listThe output will look like this:
Environment: default
+---------+-----------+
| TYPE | NAME |
+---------+-----------+
| generic | MY_SECRET |
| gorgias | my_conn |
+---------+-----------+
Environment: someother
+---------+-----------+
| TYPE | NAME |
+---------+-----------+
| generic | MY_SECRET |
+---------+-----------+Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--config-file | str | - | 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:
- Selecting an environment
- Entering a connection name
- Choosing a connection type (with search/filter)
- Filling in the credential fields for that type
bruin connections addFlag-based mode
You can also provide all parameters via flags for scripting and CI/CD usage:
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
| Flag | Type | Default | Description |
|---|---|---|---|
--environment, -e, --env | str | - | The name of the environment to add the connection to. |
--name | str | - | The name of the connection. |
--type | str | - | The type of the connection. |
--credentials | str | - | The JSON object containing the credentials. |
--config-file | str | - | The path to the .bruin.yml file. |
Example: a GCP connection
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
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:
bruin connections delete --env staging --name MY_SECRETYou can define a different path for the repo with an extra argument if you'd like:
bruin connections delete --env staging --name MY_SECRET <path-to-repo>Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--config-file | str | - | The path to the .bruin.yml file. |
Example
Delete a connection named "my-connection" from the "production" environment:
bruin connections delete -e staging -n test-connection -o jsonTest Connection
To test if a connection is valid, you can use the test command. This command runs a simple validation check for the connection.
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
| Flag | Type | Default | Description |
|---|---|---|---|
--config-file | str | - | The path to the .bruin.yml file. |
Examples
Test a connection in the default environment:
bruin connections test --name my-bigquery-connTest a connection in a specific environment:
bruin connections test --name my-snowflake-conn --env productionYou can also get the output in JSON format:
bruin connections test --name my-postgres-conn --env staging --output json