https://github.com/brendancopley/smm
π SMM - Secret Manager Maker CLI π§ββοΈ Automate secret management for AWS with ease!
https://github.com/brendancopley/smm
aws manager secret secret-manager-maker secrets-manager smm
Last synced: 6 months ago
JSON representation
π SMM - Secret Manager Maker CLI π§ββοΈ Automate secret management for AWS with ease!
- Host: GitHub
- URL: https://github.com/brendancopley/smm
- Owner: brendancopley
- License: mit
- Created: 2024-10-19T04:25:58.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2024-10-20T16:25:24.000Z (12 months ago)
- Last Synced: 2025-02-04T22:24:24.032Z (8 months ago)
- Topics: aws, manager, secret, secret-manager-maker, secrets-manager, smm
- Language: Shell
- Homepage:
- Size: 39.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π Secret Manager Maker (smm) CLI
`Secret Manager Maker (smm)` CLI π οΈ tool helps you automate π€ the process of converting π environment π configuration files π into AWS Secrets Manager π commands. Whether you are working with development π οΈ, test π§ͺ, or production π environments, this tool allows you to push secrets π€« directly to AWS Secrets Manager with ease. You can also choose between AWS CLI and Teleport (tsh) π command formats.

## π Features
- π Automatically reads your environment configuration from YAML, π or custom config files.
- π Converts the configuration into AWS Secrets Manager or Teleport secrets creation commands.
- π Supports multiple environments like development π οΈ, testing π§ͺ, and production π.
- π― Allows users to specify line ranges, custom key names π, and output scripts π.
- π Debug mode for troubleshooting.## βοΈ Installation
1. π **Clone the repository**:
```bash
git clone https://github.com/yourusername/smm-cli.git
cd smm-cli
```2. π§ **Make the script executable**:
```bash
chmod +x smm
```3. βΆοΈ **Run the CLI**:
```bash
./smm --help
```## π Usage
```bash
./smm [OPTIONS]
```### βοΈ Options
| βοΈ Option | π Description |
| ------------------- | -------------------------------------------------------------------------- |
| `-h`, `--help` | π Show help message and exit. |
| `-D` | π Enable debug mode for verbose logging. |
| `--lines RANGE` | π’ Specify a range of line numbers to read from the config file (e.g., 5-10).|
| `--keyname NAME` | π Use a custom keyName for the secrets instead of using the config. |
| `--config FILE` | π Specify a custom configuration file. Default is `smm.yaml`. |
| `--output FILE` | πΎ Specify the output script file. Default is `create_secrets.sh`. |### β¨ Example Command
1. **Generate AWS CLI commands with default config**:
By default, the tool reads from `smm.yaml` and generates the secrets creation commands in the default output file (`create_secrets.sh`).
```bash
./smm
```2. **Enable debug mode to track execution**:
```bash
./smm -D
```The debug mode will display details about the configuration file being used, the output script being generated, and the values extracted from the YAML.
3. **Specify a custom configuration file**:
Instead of the default `smm.yaml`, you can specify a custom configuration file.
```bash
./smm --config custom_config.yaml
```4. **Generate Teleport (tsh) commands**:
By changing the `format` in your `smm.yaml` to `tsh`, you can create Teleport CLI commands:
```yaml
format: tsh # in smm.yaml
```
Then run:
```bash
./smm
```5. **Custom output file**:
Specify a custom output file for the generated script:
```bash
./smm --output my_secrets_script.sh
```### Combining Multiple Options
1. **Custom keyName with line range**:
If you want to specify a custom key name while processing only a specific range of lines from the config file:
```bash
./smm --keyname MY_SECRET_KEY --lines 5-10
```In this example, `MY_SECRET_KEY` will be used for each secret, and only lines 5 to 10 of the config file will be read.
2. **Debug mode with custom keyName and custom output**:
Combine debug mode to get detailed output, specify a custom key name, and save the generated commands to a custom file:
```bash
./smm -D --keyname MY_CUSTOM_KEY --output secrets_script.sh
```This is useful when you need to debug the script and ensure the correct key name and output file are being used.
3. **Custom config file, custom output, and range of lines**:
Use a specific configuration file, output to a custom script, and process only specific lines:
```bash
./smm --config custom_config.yaml --output custom_secrets.sh --lines 10-20
```This reads the configuration from `custom_config.yaml`, writes the generated commands to `custom_secrets.sh`, and only processes lines 10 to 20 in the configuration file.
4. **Mix of AWS CLI format and a specific range of lines**:
You can specify that you only want the secrets to be created for a subset of your configuration file, using AWS CLI format:
```yaml
format: aws # in smm.yaml
```
Then run:
```bash
./smm --lines 10-30
```This will generate AWS CLI commands for secrets defined between lines 10 and 30 of the configuration.
5. **Create secrets for production environment only**:
Suppose you only want to process lines containing production-related secrets and use a custom key:
```bash
./smm --keyname PROD_SECRET_KEY --lines 50-70 --output prod_secrets.sh
```This reads the configuration file, extracts secrets from lines 50 to 70, uses the `PROD_SECRET_KEY` key name, and generates the output in `prod_secrets.sh`.
### Advanced Scenarios
1. **Multiple secrets creation with custom script for each environment**:
You can create separate scripts for each environment (dev, test, prod) by modifying the environments in your `smm.yaml` and specifying different output files:
```yaml
environments:
- name: project_name-dev # Development environment
region: us-west-2
- name: project_name-test # Test environment
region: us-west-2
- name: project_name-prod # Production environment
region: us-east-1
```Run for the development environment:
```bash
./smm --keyname DEV_SECRET_KEY --output dev_secrets.sh
```Run for the production environment:
```bash
./smm --keyname PROD_SECRET_KEY --output prod_secrets.sh
```2. **Using different configurations for staging and production**:
You can maintain separate configuration files for different environments (e.g., `staging.yaml` and `production.yaml`) and specify them as needed:
```bash
./smm --config staging.yaml --output staging_secrets.sh
./smm --config production.yaml --output production_secrets.sh
```### Custom Configuration Example
Here's an example of what your custom configuration YAML might look like:
```yaml
# custom_config.yaml
configFile: "prod/hub/config/appglobal.conf" # Path to the production config file
outputScript: "prod_secrets.sh" # The output file where the AWS CLI/Teleport commands will be writtenenvironments:
- name: project_name-prod # Production environment
region: us-east-1format: aws # Options: "tsh" (Teleport) or "aws" (AWS CLI)
```Then you can run:
```bash
./smm --config custom_config.yaml --output custom_script.sh
```### Debugging
To enable detailed debug logging to trace the behavior of the script and see the values being processed, use the `-D` option:
```bash
./smm -D --config smm.yaml --output my_debug_script.sh
```This provides detailed information about each step, such as:
- Configuration values being extracted.
- Output scripts being generated.
- Secrets and key names being processed.---
These additional examples demonstrate how you can combine different options in the `smm` CLI to fit various real-world use cases.
## π Configuration (`smm.yaml`)
`smm` uses a YAML configuration file π to define environment settings βοΈ. The default file is `smm.yaml` and looks like this:
```yaml
# smm.yaml - Configuration for the Secret Manager Maker CLIconfigFile: "secrets.conf" # The path to your application config file
outputScript: "create_secrets.sh" # The output file where the AWS CLI/Teleport commands will be writtenenvironments:
- name: project_name-dev # Development environment
region: us-west-2
- name: project_name-test # Test environment
region: us-west-2
- name: project_name-prod # Production environment
region: us-east-1format: tsh # Options: "tsh" (Teleport) or "aws" (AWS CLI)
```### π Key Components:
- **configFile**: The path π€οΈ to the config file where your key-value pairs for secrets π€« are defined.
- **outputScript**: The file where the generated AWS CLI/Teleport commands π will be saved πΎ.
- **environments**: Define your environment names π οΈ (e.g., dev, test, prod) and their associated regions π.
- **format**: Choose between `tsh` for Teleport commands or `aws` for AWS Secrets Manager commands.## π Cross-Platform Support
`smm` is designed for Unix-based systems like macOS π and Linux π§. Simply run the script in your terminal π», and it will function as expected. Ensure you have access to AWS CLI and/or Teleport CLI based on your configuration needs.
## π Example Output
Hereβs an example of what the generated script might look like when using AWS CLI:
```bash
#!/bin/bashaws secretsmanager create-secret --name project_name-dev/k8s/MY_CUSTOM_KEY --secret-string "secret_value" --region us-west-2
aws secretsmanager create-secret --name project_name-test/k8s/MY_CUSTOM_KEY --secret-string "another_secret_value" --region us-west-2
aws secretsmanager create-secret --name project_name-prod/k8s/MY_CUSTOM_KEY --secret-string "prod_secret_value" --region us-east-1
```## π Debugging
Enable the debug mode π using the `-D` option to get detailed output of the script execution:
```bash
./smm -D --config myconfig.yaml
```## π€ Contributing
1. π΄ **Fork the repository**.
2. πΏ **Create your feature branch**: `git checkout -b feature/your-feature-name`.
3. βοΈ **Commit your changes**: `git commit -m 'Add some feature'`.
4. π **Push to the branch**: `git push origin feature/your-feature-name`.
5. π¬ **Open a pull request**.## π License
This project is licensed under the MIT License π.
## π Get Started
Get started with `smm` by running:
```bash
./smm --help
```---
This `README.md` provides all the necessary details on how to use the `smm` CLI tool, its options, and how to configure and run it effectively.
π© **SMM your secrets into AWS!** Your configs deserve the best. πΌ
---
And remember, "A good secret is one that is well managed.β’"