# GCP Secret Manager CLI
### gcp-secret-manager-cli (0.0.6)
A command-line interface tool for managing secrets in Google Cloud Platform's Secret Manager service with support for bulk operations using environment files.
# Features
1. List Management
- List all secrets in your GCP project
- Filter secrets by prefix
- Display creation timestamps in local timezone
2. Secret Operations
- Add/update secrets individually
- Retrieve a single secret value
- Bulk import from environment files
- Support for environment prefixes
3. Removal Capabilities
- Delete individual secrets
- Batch deletion by prefix
- Force deletion option
4. Rich Terminal Interface
- Progress indicators
- Color-coded outputs
- Operation summaries
- Interactive confirmations
# Installation
```bash
$ pip install gcp-secret-manager-cli
```
### Prerequisites
- Python >=3.8
- GCP project with Secret Manager API enabled
- Configured GCP credentials
# Configuration
Create a `.env` file in your project root:
```plaintext
PROJECT_ID=your-gcp-project-id # Required: Your GCP Project ID
TZ=Asia/Taipei # Optional: Timezone for timestamps (default: UTC)
```
# Usage
The CLI provides two command aliases:
- `gcp-secrets`: Full command name
- `sm`: Short alias (Secret Manager)
## Command Overview
```bash
❯ sm
🔐 Secret Manager CLI Tool
```
### Environment Settings
Place the following variables in the .env file to reduce the number of commands needed when using the CLI.
| Setting | Description |
|------------|-----------------------------------------------|
| PROJECT_ID | GCP Project ID for Secret Manager operations |
| TZ | Timezone for displaying timestamps (default: UTC) |
### Available Commands
| Command | Description |
|--------------|--------------------------------|
| add | Add secrets from file or command line |
| remove (rm) | Remove secrets by prefix or key |
| list (ls) | List all secrets |
| get | Get single secret |
### Usage Examples
#### Project Configuration
```bash
# If .env file does not have PROJECT_ID configured
$ sm list -P PROJECT_ID # Specify PROJECT_ID
```
#### Adding Secrets
```bash
# From environment file
$ sm add -e # Add from default .env file
$ sm add -e .env.dev # Add from specific env file
$ sm add -e .env.dev -p DEV # Add with prefix (underscore will be added automatically: DEV_APP_VER)
# Single secret
$ sm add DB_URL "mysql://localhost" # Add single secret
```
#### Removing Secrets
```bash
# From environment file
$ sm remove -e # Remove from default .env file
$ sm remove -e .env.dev # Remove from specific env file
# By prefix or key
$ sm remove -p DEV # Remove by prefix (underscore will be added automatically)
$ sm remove DB_URL # Remove single secret
$ sm rm -f -p TEST # Force remove by prefix without confirmation
# Remove all secrets
$ sm rm --all # Remove all secrets (⚠️ DANGEROUS)
$ sm rm --all -f # Force remove all secrets without confirmation
```
#### Listing Secrets
```bash
$ sm list # List all secrets
$ sm list -p DEV # List secrets with prefix (underscore will be added automatically)
$ sm ls -p TEST # List secrets with prefix (alias)
```
#### Retrieving Secret Value
```bash
$ sm get DB_URL # Get single secret value
```
## Command Options
### Global Options
- `-P, --project-id`: Override GCP project ID
- `--version`: Show version
### Add Command
- `-e, --env-file`: Source env file
- `-p, --prefix`: Add prefix to secret names
- `KEY VALUE`: Add single secret
### Remove Command
- `-e, --env-file`: Remove from env file
- `-p, --prefix`: Remove by prefix
- `--all`: Remove all secrets (⚠️ DANGEROUS)
- `-f, --force`: Skip confirmation
- `KEY`: Remove single secret
### List Command
- `-p, --prefix`: Filter secrets by prefix
### Get Command
- `KEY`: Retrieve single secret value
# Development
### Setup
```bash
git clone https://github.com/TaiwanBigdata/gcp-secret-manager-cli.git
cd gcp-secret-manager-cli
python -m venv env
source env/bin/activate # Linux/Mac
pip install -e .
```
# Dependencies
### Core
- google-api-core>=2.23.0
- google-cloud-secret-manager>=2.21.1
- rich>=13.9.4
- click>=8.1.7
- python-dotenv>=1.0.1
# License
This project is licensed under the MIT License.
# Project Structure
```
gcp-secret-manager-cli/
├── src/
│ └── gcp_secret_manager_cli/
│ ├── core/
│ │ ├── client.py
│ │ └── manager.py
│ ├── utils/
│ │ ├── console.py
│ │ └── env.py
│ ├── __main__.py
│ └── cli.py
├── LICENSE
├── pyproject.toml
├── readgen.toml
├── README.md
└── requirements.txt
```
---
> This document was automatically generated by [ReadGen](https://github.com/TaiwanBigdata/readgen).
Raw data
{
"_id": null,
"home_page": null,
"name": "gcp-secret-manager-cli",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "cli, gcp, secret-manager",
"author": null,
"author_email": "Albert Liu <dreamerhyde@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/28/05/8c262b522fb0a08ae3955f0f9910179333997005134ff4c4d04fa25acf78/gcp_secret_manager_cli-0.0.6.tar.gz",
"platform": null,
"description": "# GCP Secret Manager CLI \n\n### gcp-secret-manager-cli (0.0.6)\nA command-line interface tool for managing secrets in Google Cloud Platform's Secret Manager service with support for bulk operations using environment files.\n\n\n# Features\n\n1. List Management\n - List all secrets in your GCP project\n - Filter secrets by prefix\n - Display creation timestamps in local timezone\n\n2. Secret Operations\n - Add/update secrets individually\n - Retrieve a single secret value\n - Bulk import from environment files\n - Support for environment prefixes\n \n3. Removal Capabilities\n - Delete individual secrets\n - Batch deletion by prefix\n - Force deletion option\n\n4. Rich Terminal Interface\n - Progress indicators\n - Color-coded outputs\n - Operation summaries\n - Interactive confirmations\n\n\n# Installation\n\n```bash\n$ pip install gcp-secret-manager-cli\n```\n\n### Prerequisites\n- Python >=3.8\n- GCP project with Secret Manager API enabled\n- Configured GCP credentials\n\n\n# Configuration\n\nCreate a `.env` file in your project root:\n```plaintext\nPROJECT_ID=your-gcp-project-id # Required: Your GCP Project ID\nTZ=Asia/Taipei # Optional: Timezone for timestamps (default: UTC)\n```\n\n\n# Usage\n\nThe CLI provides two command aliases:\n- `gcp-secrets`: Full command name\n- `sm`: Short alias (Secret Manager)\n\n## Command Overview\n```bash\n\u276f sm\n\ud83d\udd10 Secret Manager CLI Tool\n```\n\n### Environment Settings\nPlace the following variables in the .env file to reduce the number of commands needed when using the CLI.\n| Setting | Description |\n|------------|-----------------------------------------------|\n| PROJECT_ID | GCP Project ID for Secret Manager operations |\n| TZ | Timezone for displaying timestamps (default: UTC) |\n\n### Available Commands\n| Command | Description |\n|--------------|--------------------------------|\n| add | Add secrets from file or command line |\n| remove (rm) | Remove secrets by prefix or key |\n| list (ls) | List all secrets |\n| get | Get single secret |\n\n### Usage Examples\n\n#### Project Configuration\n```bash\n# If .env file does not have PROJECT_ID configured\n$ sm list -P PROJECT_ID # Specify PROJECT_ID\n```\n\n#### Adding Secrets\n```bash\n# From environment file\n$ sm add -e # Add from default .env file\n$ sm add -e .env.dev # Add from specific env file\n$ sm add -e .env.dev -p DEV # Add with prefix (underscore will be added automatically: DEV_APP_VER)\n\n# Single secret\n$ sm add DB_URL \"mysql://localhost\" # Add single secret\n```\n\n#### Removing Secrets\n```bash\n# From environment file\n$ sm remove -e # Remove from default .env file\n$ sm remove -e .env.dev # Remove from specific env file\n\n# By prefix or key\n$ sm remove -p DEV # Remove by prefix (underscore will be added automatically)\n$ sm remove DB_URL # Remove single secret\n$ sm rm -f -p TEST # Force remove by prefix without confirmation\n\n# Remove all secrets\n$ sm rm --all # Remove all secrets (\u26a0\ufe0f DANGEROUS)\n$ sm rm --all -f # Force remove all secrets without confirmation\n```\n\n#### Listing Secrets\n```bash\n$ sm list # List all secrets\n$ sm list -p DEV # List secrets with prefix (underscore will be added automatically)\n$ sm ls -p TEST # List secrets with prefix (alias)\n```\n\n#### Retrieving Secret Value\n```bash\n$ sm get DB_URL # Get single secret value\n```\n\n## Command Options\n### Global Options\n- `-P, --project-id`: Override GCP project ID\n- `--version`: Show version\n\n### Add Command\n- `-e, --env-file`: Source env file\n- `-p, --prefix`: Add prefix to secret names\n- `KEY VALUE`: Add single secret\n\n### Remove Command\n- `-e, --env-file`: Remove from env file\n- `-p, --prefix`: Remove by prefix\n- `--all`: Remove all secrets (\u26a0\ufe0f DANGEROUS)\n- `-f, --force`: Skip confirmation\n- `KEY`: Remove single secret\n\n### List Command\n- `-p, --prefix`: Filter secrets by prefix\n\n### Get Command\n- `KEY`: Retrieve single secret value\n\n\n# Development\n\n### Setup\n```bash\ngit clone https://github.com/TaiwanBigdata/gcp-secret-manager-cli.git\ncd gcp-secret-manager-cli\npython -m venv env\nsource env/bin/activate # Linux/Mac\npip install -e .\n```\n\n\n# Dependencies\n\n### Core\n- google-api-core>=2.23.0\n- google-cloud-secret-manager>=2.21.1\n- rich>=13.9.4\n- click>=8.1.7\n- python-dotenv>=1.0.1\n\n\n# License\n\nThis project is licensed under the MIT License.\n\n\n# Project Structure\n\n```\ngcp-secret-manager-cli/\n\u251c\u2500\u2500 src/\n\u2502 \u2514\u2500\u2500 gcp_secret_manager_cli/\n\u2502 \u251c\u2500\u2500 core/\n\u2502 \u2502 \u251c\u2500\u2500 client.py\n\u2502 \u2502 \u2514\u2500\u2500 manager.py\n\u2502 \u251c\u2500\u2500 utils/\n\u2502 \u2502 \u251c\u2500\u2500 console.py\n\u2502 \u2502 \u2514\u2500\u2500 env.py\n\u2502 \u251c\u2500\u2500 __main__.py\n\u2502 \u2514\u2500\u2500 cli.py\n\u251c\u2500\u2500 LICENSE\n\u251c\u2500\u2500 pyproject.toml\n\u251c\u2500\u2500 readgen.toml\n\u251c\u2500\u2500 README.md\n\u2514\u2500\u2500 requirements.txt\n```\n\n\n---\n> This document was automatically generated by [ReadGen](https://github.com/TaiwanBigdata/readgen).\n",
"bugtrack_url": null,
"license": null,
"summary": "A command-line tool for managing GCP Secret Manager",
"version": "0.0.6",
"project_urls": {
"Homepage": "https://github.com/TaiwanBigdata/gcp-secret-manager-cli",
"Repository": "https://github.com/TaiwanBigdata/gcp-secret-manager-cli.git"
},
"split_keywords": [
"cli",
" gcp",
" secret-manager"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fc49134d6b7afd2320e6f7a243afd70b6ea6546d9506a37a0c46c6bc1afb9f10",
"md5": "619dcd115a75913138e59806f597d800",
"sha256": "e39c0d2cdacbefbdd196f243eac73b27fb94977883b3e835d2e2d0d0c27ba973"
},
"downloads": -1,
"filename": "gcp_secret_manager_cli-0.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "619dcd115a75913138e59806f597d800",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 14792,
"upload_time": "2024-12-31T05:41:57",
"upload_time_iso_8601": "2024-12-31T05:41:57.158656Z",
"url": "https://files.pythonhosted.org/packages/fc/49/134d6b7afd2320e6f7a243afd70b6ea6546d9506a37a0c46c6bc1afb9f10/gcp_secret_manager_cli-0.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "28058c262b522fb0a08ae3955f0f9910179333997005134ff4c4d04fa25acf78",
"md5": "ee8873f21d59a0b6489aa6a54c12a1c4",
"sha256": "fbdd2810c80ec638bb302b6e233d43e7616d5bbda5985db0570dd6449130b148"
},
"downloads": -1,
"filename": "gcp_secret_manager_cli-0.0.6.tar.gz",
"has_sig": false,
"md5_digest": "ee8873f21d59a0b6489aa6a54c12a1c4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 12846,
"upload_time": "2024-12-31T05:42:00",
"upload_time_iso_8601": "2024-12-31T05:42:00.445378Z",
"url": "https://files.pythonhosted.org/packages/28/05/8c262b522fb0a08ae3955f0f9910179333997005134ff4c4d04fa25acf78/gcp_secret_manager_cli-0.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-31 05:42:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "TaiwanBigdata",
"github_project": "gcp-secret-manager-cli",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "google-api-core",
"specs": [
[
"==",
"2.23.0"
]
]
},
{
"name": "google-cloud-secret-manager",
"specs": [
[
"==",
"2.21.1"
]
]
},
{
"name": "rich",
"specs": [
[
"==",
"13.9.4"
]
]
},
{
"name": "click",
"specs": [
[
"==",
"8.1.7"
]
]
},
{
"name": "python-dotenv",
"specs": [
[
"==",
"1.0.1"
]
]
}
],
"lcname": "gcp-secret-manager-cli"
}