Secrets Management with Kubiya CLI
This guide provides comprehensive instructions for managing sensitive data and secrets securely with the Kubiya CLI.
Understanding Secrets in Kubiya
Secrets in Kubiya are encrypted pieces of sensitive information that can be securely stored, referenced, and used in your tools and automations without exposing their values. Common examples include:
API keys and access tokens
Database credentials
Authentication certificates
Environment-specific configurations
Service account credentials
Listing Secrets
To view all secrets in your organization:
For JSON format output:
Creating Secrets
Creating a Secret with a Value
To create a new secret with a directly specified value:
Creating a Secret from a File
For larger secrets or to avoid having the secret in your shell history:
Required Parameters:
--name
: A unique name for your secret
One of these is required:
--value
: The sensitive value to store securely--from-file
: Path to a file containing the secret value
Optional Parameters:
--description
: Description of the secret's purpose--tags
: Tags for categorizing secrets--expiry
: Expiration date for the secret (YYYY-MM-DD)
Getting Secret Information
Viewing Secret Metadata
To get metadata about a specific secret (without exposing its value):
This shows the secret's metadata, such as creation date, description, and tags, but not the actual secret value.
Retrieving a Secret Value
To retrieve the actual value of a secret (use with caution):
For JSON format output:
Editing Secrets
In Your Default Editor
To edit a secret's value in your preferred text editor:
This will open your default editor (set by $EDITOR environment variable, defaults to vim if not set) with the current secret value, allowing you to make changes securely.
Updating Secret Value
To modify an existing secret value directly:
Updating from a File
Updating Metadata Only
To update only the metadata:
Deleting Secrets
To remove a secret:
You'll be prompted to confirm the deletion.
To bypass confirmation:
Using Secrets in Tools
Secrets can be referenced in tool definitions using the $secret:
prefix:
When this tool is executed, Kubiya securely injects the secret values into the environment variables without exposing them.
Rotating Secrets
It's a security best practice to regularly rotate your secrets:
To generate a secure random value:
Secret Security Measures
Encryption
Kubiya encrypts all secrets using industry-standard encryption algorithms. The secrets are never stored in plaintext.
Access Control
Only authorized users with the appropriate permissions can access or use secrets. You can manage permissions in the Kubiya dashboard.
Audit Trail
All operations involving secrets (creation, usage, updates, deletions) are logged in the audit trail:
Safe File Handling
When editing secrets with the edit
command:
Temporary files are created for editing
These files are automatically deleted after editing is complete
The files are created with appropriate permissions to prevent unauthorized access
Secret Scopes
Secrets can be scoped to specific contexts:
Organization-wide Secrets
Available to all teammates and tools:
Teammate-specific Secrets
Available only to specific teammates:
Source-specific Secrets
Available only to tools from specific sources:
Importing and Exporting Secrets
Importing Multiple Secrets
You can import multiple secrets from a JSON file:
Example secrets.json
format:
Exporting Secrets (Metadata Only)
To export secret metadata (without values) for backup or migration:
Integration with External Secret Managers
Kubiya can integrate with external secret management services:
AWS Secrets Manager
Hashicorp Vault
End-to-End Example: Setting Up Secure CI/CD Pipeline with Secrets
Here's a complete workflow for managing secrets in a CI/CD pipeline:
Step 1: Create the Required Secrets
Step 2: Create a Deployment Tool That Uses Secrets
Create a tool definition file with secret references:
Step 3: Execute the Tool
The deployment runs with all the necessary credentials, but the secret values are never exposed in logs or terminal output.
Step 4: Update a Secret When Needed
If you need to update a secret credential:
Step 5: Rotate Secrets Regularly
Set up a scheduled task to remind you to rotate secrets:
Step 6: Audit Secret Usage
Review the audit logs to ensure proper secret usage:
For more information on secrets management, visit the official documentation.
Was this helpful?