https://github.com/kometen/rusty-psql
Wrapper around psql where connection information is pulled from Azure Key Vault
https://github.com/kometen/rusty-psql
1password-cli azure-key-vault psql
Last synced: about 1 month ago
JSON representation
Wrapper around psql where connection information is pulled from Azure Key Vault
- Host: GitHub
- URL: https://github.com/kometen/rusty-psql
- Owner: kometen
- License: mit
- Created: 2024-10-25T12:46:56.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-20T09:03:55.000Z (over 1 year ago)
- Last Synced: 2025-02-17T12:33:47.048Z (over 1 year ago)
- Topics: 1password-cli, azure-key-vault, psql
- Language: Rust
- Homepage: https://github.com/kometen/rusty-psql
- Size: 192 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rusty_psql
A wrapper around psql so information about host to connect to, database, password is retrieved from Azure Key Vault
and URL to Azure Key Vault from 1password thus avoiding storing passwords in cleartext locally.
Requires 1password and Azure command line utilities installed locally, an Azure-subscription, a PostgreSQL-client.
Log in with `az login`.
Add an entry in 1password that can be accessed by the program. The path is formatted in Rust.
```
let op_path = format!("op://Production/AzureKeyVault{}/url", key);
```
An example of a key can be `Invoice` and the path becomes `op://Production/AzureKeyVaultInvoice/url`.

Create an Azure Key Vault named `invoice` and add the following secrets to Azure Key Vault:
```
db-host
db-name
db-pwd
db-user
db-domain
```
Change the path to suit your own requirement with the format `op://[vault-name]/[item]/[text-field]/[value]` in 1password.
Clone the repository, test, build and run with
```
cargo test
cargo build [--release]
./target/release/rusty_psql -n invoice
```
Install via `brew tap`.
```
brew tap kometen/rusty-psql
brew install rusty-psql
```
Build and run the container-image.
```
docker build -t rusty_psql:dev .
docker run --user rusty_psql_user rusty_psql:dev
```
The container will not inherit the environment from the shell so running from the container will not work.
I had much help from Claude. Used the editor zed at https://github.com/zed-industries/zed.