@clever.gy/gcloud-env-secrets
v1.0.1
Published
Utility to generate .env files from a template by retrieving and inserting secrets from Google Cloud Secret Manager
Readme
@clever.gy/gcloud-env-secrets
CLI tool to retrieve secrets from Google Cloud Secret Manager and generate .env files based on templates.
📋 Description
@clever.gy/gcloud-env-secrets is a command-line tool that generates environment files (.env) by replacing placeholders in a template with actual values retrieved from Google Cloud Secret Manager.
✨ Features
- 🔐 Retrieves secrets from Google Cloud Secret Manager
- 📝 Generates
.envfiles from templates with placeholders - ✅ Validates
gcloudconfiguration before execution - 🛡️ Prompts for confirmation before overwriting existing files
📦 Installation
npm install -g @clever.gy/gcloud-env-secretsOr install locally in a project:
npm install --save-dev @clever.gy/gcloud-env-secrets🔧 Prerequisites
Google Cloud SDK (gcloud) installed and configured
- Installation guide: https://cloud.google.com/sdk/docs/install
- macOS (Homebrew):
brew install --cask google-cloud-sdk
Authentication with Google Cloud
gcloud auth application-default loginGCP project configured
gcloud config set project YOUR_GCP_PROJECTRequired permissions: Your account must have permissions to access Secret Manager in the specified project.
🚀 Usage
gcloud-env-secrets <gcpProjectName> <envFileTemplatePath> <envFileOutputPath>Example:
gcloud-env-secrets my-gcp-project .env.template .envParameters
gcpProjectName: Google Cloud Platform project nameenvFileTemplatePath: Path to the.envtemplate file with placeholdersenvFileOutputPath: Path where the final.envfile will be generated
📝 Template format
Create a template file with placeholders using the format $$SECRET{secret-name}:
DATABASE_URL=$$SECRET{database-url}
API_KEY=$$SECRET{api-key}
JWT_SECRET=$$SECRET{jwt-secret}The tool will find all placeholders and replace them with actual values from Secret Manager.
🛠️ Development
npm run lint # Lint the code
npm start # Run in development mode
npm run build # Build the project🔐 Security
- ⚠️ Never commit generated
.envfiles to your repository - ✅ Use
.gitignoreto exclude.envfiles - ✅ Keep templates (
.env.template) in the repository without sensitive values
