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.
- π 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.
-
π Clone the repository:
git clone https://github.com/yourusername/smm-cli.git cd smm-cli
-
π§ Make the script executable:
chmod +x smm
-
βΆοΈ Run the CLI:./smm --help
./smm [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 . |
-
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
)../smm
-
Enable debug mode to track execution:
./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.
-
Specify a custom configuration file: Instead of the default
smm.yaml
, you can specify a custom configuration file../smm --config custom_config.yaml
-
Generate Teleport (tsh) commands: By changing the
format
in yoursmm.yaml
totsh
, you can create Teleport CLI commands:format: tsh # in smm.yaml
Then run:
./smm
-
Custom output file: Specify a custom output file for the generated script:
./smm --output my_secrets_script.sh
-
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:
./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. -
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:
./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.
-
Custom config file, custom output, and range of lines: Use a specific configuration file, output to a custom script, and process only specific lines:
./smm --config custom_config.yaml --output custom_secrets.sh --lines 10-20
This reads the configuration from
custom_config.yaml
, writes the generated commands tocustom_secrets.sh
, and only processes lines 10 to 20 in the configuration file. -
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:
format: aws # in smm.yaml
Then run:
./smm --lines 10-30
This will generate AWS CLI commands for secrets defined between lines 10 and 30 of the configuration.
-
Create secrets for production environment only: Suppose you only want to process lines containing production-related secrets and use a custom key:
./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 inprod_secrets.sh
.
-
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: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:
./smm --keyname DEV_SECRET_KEY --output dev_secrets.sh
Run for the production environment:
./smm --keyname PROD_SECRET_KEY --output prod_secrets.sh
-
Using different configurations for staging and production: You can maintain separate configuration files for different environments (e.g.,
staging.yaml
andproduction.yaml
) and specify them as needed:./smm --config staging.yaml --output staging_secrets.sh ./smm --config production.yaml --output production_secrets.sh
Here's an example of what your custom configuration YAML might look like:
# 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 written
environments:
- name: project_name-prod # Production environment
region: us-east-1
format: aws # Options: "tsh" (Teleport) or "aws" (AWS CLI)
Then you can run:
./smm --config custom_config.yaml --output custom_script.sh
To enable detailed debug logging to trace the behavior of the script and see the values being processed, use the -D
option:
./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.
smm
uses a YAML configuration file π to define environment settings βοΈ. The default file is smm.yaml
and looks like this:
# smm.yaml - Configuration for the Secret Manager Maker CLI
configFile: "secrets.conf" # The path to your application config file
outputScript: "create_secrets.sh" # The output file where the AWS CLI/Teleport commands will be written
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
format: tsh # Options: "tsh" (Teleport) or "aws" (AWS CLI)
- 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 oraws
for AWS Secrets Manager commands.
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.
Hereβs an example of what the generated script might look like when using AWS CLI:
#!/bin/bash
aws 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
Enable the debug mode π using the -D
option to get detailed output of the script execution:
./smm -D --config myconfig.yaml
- π΄ Fork the repository.
- πΏ Create your feature branch:
git checkout -b feature/your-feature-name
. - βοΈ Commit your changes:
git commit -m 'Add some feature'
. - π Push to the branch:
git push origin feature/your-feature-name
. - π¬ Open a pull request.
This project is licensed under the MIT License π.
Get started with smm
by running:
./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.β’"