1Password
Experimental
Reading connection settings from 1Password is experimental and may change.
A connection in .bruin.yml can read some or all of its settings from a 1Password item, so secrets don't have to be written in the file. Unlike the --secrets-backend options, this works per connection: everything else in .bruin.yml stays as it is.
Requirements
Bruin reads items with the 1Password CLI (op), so op must be installed and signed in. The simplest way is to turn on Settings → Developer → Integrate with 1Password CLI in the 1Password desktop app; 1Password then asks you to approve access when Bruin first reads an item. Any other way op can sign in, such as a service account token, works too.
Scripts, CI and other tools
- Without a terminal, for example when another tool or a CI job runs Bruin,
opcan't ask for a password, so Bruin gives it no input andopfails right away instead of waiting. Approval in the 1Password desktop app still works. - For CI and other unattended runs, set
OP_SERVICE_ACCOUNT_TOKENto a service account token.opthen reads items without any prompt. - Each call to
opis stopped after 2 minutes, for example when a 1Password prompt is never answered, and Bruin reports which step timed out. - If you are signed in to several 1Password accounts, set
OP_ACCOUNTto the one to read from.
Linking a connection to an item
Add bruin_external_vault to the connection and remove the settings that are now in the item:
environments:
default:
connections:
postgres:
- name: analytics_pg
database: analytics
bruin_external_vault: op://Employee/analytics-postgresThe link is op://<vault>/<item>, using the vault and item names as they appear in 1Password, or their IDs. bruin connections vaults lists the vaults you can use, with the start of the link for each. Each connection in each environment can point to its own item.
To add a linked connection from the command line, pass the link with the other settings:
bruin connections add --env default --name analytics_pg --type postgres \
--credentials '{"database": "analytics", "bruin_external_vault": "op://Employee/analytics-postgres"}'How item fields are matched
Each field of the item whose label is a setting name is used for that setting, for example a field labelled password sets password.
- Labels are matched ignoring case, and spaces or dashes count as underscores:
Passwordandpool max connsboth match. - 1Password's built-in labels
serverandhostnamesethost, so a 1Password Database item works as it is. - Fields that match no setting, such as notes, are ignored.
- A setting that has a value in
.bruin.ymlcan't also come from the item, and two fields can't set the same setting. Bruin reports either case as an error, without showing the values. A setting left empty,falseor0in.bruin.ymlcounts as not set, so the item can fill it. - Settings that make Bruin use something on your machine can't come from the item: local files such as
service_account_file,private_key_path, thessl_*_pathsettings, an Oraclewalletor a DuckDBpath, folders such astemp_directory, and your own cloud login, such asprofileoruse_application_default_credentials. Keep them in.bruin.yml, or store a file's contents in the item instead, for example inservice_account_jsonorprivate_key. - Settings that turn encryption or certificate checks on or off, such as
ssl_mode,tls_skip_verifyordisable_ssl, can't come from the item either. Keep them in.bruin.yml.
Anyone who can edit an item decides where its connection points, such as its host, account or bucket, just like anyone who can edit .bruin.yml. Share a vault only with people you would let change your connections.
When Bruin contacts 1Password
Bruin reads an item only when a command opens that connection, for example when running an asset that uses it or testing it with bruin connections test. Commands that don't open connections, such as render, lineage, validate --fast and connections list, never contact 1Password. Each item is read at most once per command.
bruin validatewithout--fastdry-runs queries, so it reads the items of the connections those queries use.bruin runhides values read from an item in the run's output and log file as soon as they are read. To do that it also reads, before the run starts, the items of every connection used anywhere in the pipeline, even when running a single asset.--mask-credentials=falseturns both off.
Values read from 1Password are never written back to .bruin.yml, and commands that change other connections or environments keep each link as it is.
bruin connections list -o json shows each linked connection's bruin_external_vault, but never the values that come from the item. To change a linked connection with bruin connections delete and bruin connections add, pass bruin_external_vault again in --credentials; without it, the connection is saved without its link.
Settings to keep in .bruin.yml
Some settings are read straight from .bruin.yml without opening the connection, so keep them in the file:
database,catalogandproject_id, used by column lineagemax_concurrent_assetsuse_cloudquery_results_pathfor Athena, andclusterfor ClickHouse
The Bruin Cloud connection (bruin) can't be linked yet: bruin login and the cloud commands read its token from .bruin.yml.
Connections read from a secrets backend with --secrets-backend can't be linked either.
Values in the item are used as they are: ${ENV_VAR} references in them are not expanded.