mirror of
https://github.com/hanzoai/kms.git
synced 2026-10-30 14:57:36 +00:00
Public-facing docs, metadata, and branding: - README.md: remove fork attribution, rebrand intro - package.json: clean description - CONTRIBUTING.md, SECURITY.md: remove Infisical mentions - LLM.md: update image name, remove fork language - docs/docs.json: rebrand name, nav labels, social links, footer URLs - company/ handbook & docs: rebrand all Infisical mentions - .env.migration.example: use hanzokms credentials - flake.nix: update description, remove infisical package - .github/ISSUE_TEMPLATE/config.yml: fix broken ghcr.io URLs - docs/ (24 files): rebrand prose, mermaid diagrams, API URLs - docs/Dockerfile: update spec fetch URL Removed upstream assets: - img/infisical_github_repo.png, infisical_github_repo2.png - .github/images/star-infisical.gif - .github/images/.!35663!deploy-to-aws.png (corrupted empty) NOT changed (would break code/legal): - LICENSE (MIT copyright must stay) - backend/src/ee/LICENSE.md (upstream enterprise license) - backend/package.json (@infisical/* npm deps) - Dockerfiles (apt-get install infisical CLI) - env var names (INFISICAL_TOKEN, INF_APP_CONNECTION_*) - docs.json page paths (require file renames) - frontend/dist/locales (compiled translation keys)
209 lines
6.3 KiB
Plaintext
209 lines
6.3 KiB
Plaintext
---
|
|
title: "hanzo-kms export"
|
|
description: "Export KMS secrets from CLI into different file formats"
|
|
---
|
|
|
|
```bash
|
|
hanzo-kms export [options]
|
|
```
|
|
|
|
## Description
|
|
|
|
Export environment variables from the platform into a file format. By default, output is sent to stdout (standard output), but you can use the `--output-file` flag to save directly to a file.
|
|
|
|
## Subcommands & flags
|
|
|
|
<Accordion title="hanzo-kms export" defaultOpen="true">
|
|
Use this command to export environment variables from the platform into a raw file formats
|
|
|
|
```bash
|
|
$ hanzo-kms export
|
|
|
|
# Export variables to a .env file
|
|
hanzo-kms export > .env
|
|
hanzo-kms export --output-file=./.env
|
|
|
|
# Export variables to a .env file (with export keyword)
|
|
hanzo-kms export --format=dotenv-export > .env
|
|
hanzo-kms export --format=dotenv-export --output-file=./.env
|
|
|
|
# Export variables to a JSON file
|
|
hanzo-kms export --format=json > secrets.json
|
|
hanzo-kms export --format=json --output-file=./secrets.json
|
|
|
|
# Export variables to a YAML file
|
|
hanzo-kms export --format=yaml > secrets.yaml
|
|
hanzo-kms export --format=yaml --output-file=./secrets.yaml
|
|
|
|
# Render secrets using a custom template file
|
|
hanzo-kms export --template=<path to template>
|
|
```
|
|
|
|
### Environment variables
|
|
|
|
<Accordion title="KMS_TOKEN">
|
|
Used to fetch secrets via a [machine identities](/documentation/platform/identities/machine-identities) apposed to logged in credentials. Simply, export this variable in the terminal before running this command.
|
|
|
|
```bash
|
|
# Example
|
|
export KMS_TOKEN=$(hanzo-kms login --method=universal-auth --client-id=<identity-client-id> --client-secret=<identity-client-secret> --silent --plain) # --plain flag will output only the token, so it can be fed to an environment variable. --silent will disable any update messages.
|
|
```
|
|
|
|
<Info>
|
|
Alternatively, you may use service tokens.
|
|
|
|
```bash
|
|
# Example
|
|
export KMS_TOKEN=<service-token>
|
|
```
|
|
|
|
</Info>
|
|
</Accordion>
|
|
|
|
<Accordion title="KMS_DISABLE_UPDATE_CHECK">
|
|
Used to disable the check for new CLI versions. This can improve the time it takes to run this command. Recommended for production environments.
|
|
|
|
To use, simply export this variable in the terminal before running this command.
|
|
|
|
```bash
|
|
# Example
|
|
export KMS_DISABLE_UPDATE_CHECK=true
|
|
```
|
|
|
|
</Accordion>
|
|
|
|
### flags
|
|
|
|
<Accordion title="--output-file">
|
|
The path to write the output file to. Can be a full file path, directory, or filename.
|
|
|
|
```bash
|
|
# Export to specific file
|
|
hanzo-kms export --format=json --output-file=./secrets.json
|
|
|
|
# Export to directory (uses default filename based on format)
|
|
hanzo-kms export --format=yaml --output-file=./
|
|
```
|
|
|
|
**When `--output-file` is specified:**
|
|
- Secrets are saved directly to the specified file
|
|
- A success message is displayed showing the file path
|
|
- For directories: adds default filename `secrets.{format}` (e.g., `secrets.json`, `secrets.yaml`)
|
|
- For dotenv formats in directories: uses `.env` as the filename
|
|
|
|
**When `--output-file` is NOT specified (default behavior):**
|
|
- Output is sent to stdout (standard output)
|
|
- You can use shell redirection like `hanzo-kms export > secrets.json`
|
|
- Maintains backwards compatibility with existing scripts
|
|
|
|
<Warning>
|
|
If you're using shell redirection and your token expires, re-authentication will fail because the prompt can't display properly due to the redirection.
|
|
</Warning>
|
|
|
|
</Accordion>
|
|
|
|
<Accordion title="--template">
|
|
The `--template` flag specifies the path to the Go template file used for rendering secrets. When using templates, you can omit the other format flags.
|
|
|
|
```text my-template-file
|
|
{{$secrets := secret "<kms-project-id>" "<environment-slug>" "<folder-path>"}}
|
|
{{$length := len $secrets}}
|
|
{{- "{"}}
|
|
{{- with $secrets }}
|
|
{{- range $index, $secret := . }}
|
|
"{{ $secret.Key }}": "{{ $secret.Value }}"{{if lt $index (minus $length 1)}},{{end}}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{ "}" -}}
|
|
```
|
|
|
|
```bash
|
|
# Example
|
|
hanzo-kms export --template="/path/to/template/file"
|
|
```
|
|
|
|
<Tip>
|
|
The KMS CLI templating engine also supports Sprig library templating functions to help you transform your secrets further.
|
|
You can read more about the available functions [here](/integrations/platforms/kubernetes/overview#available-helper-functions).
|
|
</Tip>
|
|
|
|
</Accordion>
|
|
|
|
<Accordion title="--env">
|
|
Used to set the environment that secrets are pulled from.
|
|
|
|
```bash
|
|
# Example
|
|
hanzo-kms export --env=prod
|
|
```
|
|
|
|
Note: this flag only accepts environment slug names not the fully qualified name. To view the slug name of an environment, visit the project settings page.
|
|
|
|
default value: `dev`
|
|
|
|
</Accordion>
|
|
|
|
<Accordion title="--projectId">
|
|
By default the project id is retrieved from the `.kms.json` located at the root of your local project.
|
|
This flag allows you to override this behavior by explicitly defining the project to fetch your secrets from.
|
|
|
|
```bash
|
|
# Example
|
|
|
|
hanzo-kms export --projectId=XXXXXXXXXXXXXX
|
|
```
|
|
|
|
</Accordion>
|
|
|
|
<Accordion title="--expand">
|
|
Parse shell parameter expansions in your secrets (e.g., `${DOMAIN}`)
|
|
|
|
Default value: `true`
|
|
|
|
</Accordion>
|
|
|
|
<Accordion title="--include-imports">
|
|
By default imported secrets are available, you can disable it by setting this option to false.
|
|
|
|
Default value: `true`
|
|
</Accordion>
|
|
|
|
<Accordion title="--format">
|
|
Format of the output file. Accepted values: `dotenv`, `dotenv-export`, `csv`, `json` and `yaml`
|
|
|
|
Default value: `dotenv`
|
|
|
|
</Accordion>
|
|
|
|
<Accordion title="--secret-overriding">
|
|
Prioritizes personal secrets with the same name over shared secrets
|
|
|
|
Default value: `true`
|
|
|
|
</Accordion>
|
|
|
|
<Accordion title="--path">
|
|
The `--path` flag indicates which project folder secrets will be injected from.
|
|
|
|
```bash
|
|
# Example
|
|
hanzo-kms export --path="/path/to/folder" --env=dev
|
|
```
|
|
|
|
</Accordion>
|
|
|
|
<Accordion title="--tags">
|
|
When working with tags, you can use this flag to filter and retrieve only secrets that are associated with a specific tag(s).
|
|
|
|
```bash
|
|
# Example
|
|
hanzo-kms export --tags=tag1,tag2,tag3 --env=dev
|
|
```
|
|
|
|
Note: you must reference the tag by its slug name not its fully qualified name. Go to project settings to view all tag slugs.
|
|
|
|
By default, all secrets are fetched
|
|
|
|
</Accordion>
|
|
|
|
</Accordion> |