aws-secret-cli
v1.0.2
Published
A command-line interface tool for managing AWS Secrets Manager with .env file integration.
Maintainers
Readme
AWS Secrets CLI
A command-line interface tool for managing AWS Secrets Manager with .env file integration.
Features
- Interactive initialization and configuration
- Manage AWS Secrets Manager directly from the command line
- Sync between .env files and AWS Secrets Manager
- Support for multiple environments
- Secure credential handling
- Easy secret management workflow
Installation
npm install -g aws-secret-cli
Quick Start
- Initialize the configuration:
aws-secret-cli init
- Add a secret:
aws-secret-cli add DATABASE_URL "postgresql://user:pass@localhost:5432/db"
- List all secrets:
aws-secret-cli list
- Write secrets to .env file:
aws-secret-cli write
- Sync from .env to AWS:
aws-secret-cli sync
Commands
init
Initialize AWS Secrets Manager configuration
aws-secret-cli init
add
Add or update a secret
aws-secret-cli add KEY VALUE [options]
Options:
-e, --environment <env> environment (dev/staging/prod) (default: "dev")
--write write to .env file after adding (default: false)
get
Get a secret value
aws-secret-cli get KEY
remove
Remove a secret
aws-secret-cli remove KEY [options]
Options:
--write write to .env file after removing (default: false)
list
List all secrets
aws-secret-cli list [options]
Options:
-v, --values show secret values (default: false)
write
Write secrets to .env file
aws-secret-cli write [options]
Options:
-e, --environment <env> environment (default: "development")
-f, --filename <file> output filename (default: ".env")
sync
Sync secrets from .env file to AWS Secrets Manager
aws-secret-cli sync [options]
Options:
-f, --filename <file> input filename (default: ".env")
-m, --mode <mode> sync mode (merge/overwrite) (default: "merge")
-d, --dry-run show what would be updated without making changes
Configuration
The tool stores its configuration in .secrets-config.json
in your project root:
{
"region": "us-east-1",
"secretName": "my-app-secrets"
}
AWS Credentials
You can authenticate with AWS in two ways:
- Using AWS CLI credentials (recommended)
- Manual credential entry during initialization
Environment Variables
The following environment variables can be used to override configuration:
AWS_REGION
: Override AWS regionAWS_SECRET_NAME
: Override secret name
Error Handling
The tool provides detailed error messages and validation:
- AWS credential validation
- Region validation
- Secret name validation
- Configuration validation
Best Practices
- Always use
--dry-run
with sync command first - Keep
.secrets-config.json
in.gitignore
- Use different secret names for different environments
- Regularly backup your secrets
- Use meaningful secret names
Contributing
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
APACHE2.0 - see LICENSE file for details