Skip to main content

A simple search and replace command line utility for Hashicorp Vault

Project description

vault-search-replace

Simple Python Script to Search (and replace) secrets content in hashicorp vault.

Rationale

Recently, I have come across the fact that no API allows to simply search for values within secrets. The specific use case I am working on is to change database connection strings for java based microservices.

Running the script

Best option is to install uv. After that you can run the script with

uvx vault_search_replace

or

uv tool install vault_search_replace

The package is published on PyPI and all the dependencies are installed automatically.

Usage

vault-search-replace --help   
                                                                                                                          
 Usage: vault-search-replace [OPTIONS] COMMAND [ARGS]...                                                                  
                                                                                                                          
 An utility to search and replace Vault secrets.                                                                          
                                                                                                                          
╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --verbose  -v        Enable verbose logging                                                                            │
│ --help               Show this message and exit.                                                                       │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ search   Search strings in Hashicorp Vault secrets.                                                                    │
│ replace  Search and replace strings in Hashicorp Vault secrets.                                                        │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
vault-search-replace search --help
Vault Search Replace v0.3.0
                                                                                                                          
 Usage: vault-search-replace search [OPTIONS] STRING_TO_SEARCH VAULT_NAMESPACE                                            
                                    VAULT_BASE_URL VAULT_ACCESS_TOKEN                                                     
                                                                                                                          
 Search strings in Hashicorp Vault secrets.                                                                               
                                                                                                                          
╭─ Arguments ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *    string_to_search        TEXT  String to Search [required]                                                         │
│ *    vault_namespace         TEXT  Vault Namespace [required]                                                          │
│ *    vault_base_url          TEXT  Vault Base url to Search [required]                                                 │
│ *    vault_access_token      TEXT  Vault Access Token [required]                                                       │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --help          Show this message and exit.                                                                            │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
vault-search-replace replace --help
Vault Search Replace v0.3.0
                                                                                                                          
 Usage: vault-search-replace replace [OPTIONS] STRING_TO_SEARCH VAULT_NAMESPACE                                           
                                     VAULT_BASE_URL VAULT_ACCESS_TOKEN                                                    
                                     [REPLACEMENT_STRING]                                                                 
                                                                                                                          
 Search and replace strings in Hashicorp Vault secrets.                                                                   
                                                                                                                          
╭─ Arguments ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *    string_to_search          TEXT  String to Search [required]                                                       │
│ *    vault_namespace           TEXT  Vault Namespace [required]                                                        │
│ *    vault_base_url            TEXT  Vault Base url to Search [required]                                               │
│ *    vault_access_token        TEXT  Vault Access Token [required]                                                     │
│      [replacement_string]      TEXT  String to Replace                                                                 │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --execute          Apply the changes (default is dry-run)                                                              │
│ --help             Show this message and exit.                                                                         │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Command Line Parameters:

Common to both commands:

string_to_search vault_namespace vault_base_url vault_access_token

Only for replace

string_to_replace

Options - on replace command

--execute - confirm the execution

As of this release, the search is very simple (python str.find function).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vault_search_replace-0.3.0.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vault_search_replace-0.3.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file vault_search_replace-0.3.0.tar.gz.

File metadata

  • Download URL: vault_search_replace-0.3.0.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for vault_search_replace-0.3.0.tar.gz
Algorithm Hash digest
SHA256 24a0ba0c66d45e42f2e2e61508af353a98f7adc1fc52e492cd3ff81f579864e2
MD5 787e99b108e8cb4124f9af99828285a5
BLAKE2b-256 21c4a5a00db48085f34e907c2afcd9f528d0ad9d5b5e6854f501ec81a0eb1250

See more details on using hashes here.

File details

Details for the file vault_search_replace-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: vault_search_replace-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for vault_search_replace-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db844f97d54a49a2bea2940a8950578dbc3478d28d75125fa4cf14db35cc4bea
MD5 2f0b642cba34ffdb2341f567e33f1f5d
BLAKE2b-256 bab14ac760855066b58288095c5ac77b62d8fc7c28b48af560cd8af0c231fc1f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page