agent generate-config
Generates a simple Vault Agent configuration file from the given parameters.
Currently, the only supported configuration type is env-template
, which
helps you generate a configuration file with environment variable templates
for running Vault Agent in
process supervisor
mode.
For every specified secret -path
, the command will attempt to generate one or
multiple env_template
entries based on the JSON
key(s) stored in the
specified secret. If the secret -path
ends with /*
, the command will
attempt to recurse through the secrets tree rooted at the given path,
generating env_template
entries for each encountered secret. Currently,
only kv-v1 and
kv-v2 paths are supported.
The command specified in the -exec
option will be used to generate an
exec
entry, which will tell Vault Agent which child process to run.
In addition to the env_template
entries, the command generates an auto_auth
section with token_file
authentication method. While this method is very
convenient for local testing, it should NOT be used in production. In a
production environment, please use any other
Auto-Auth method instead.
By default, the file will be generated in the local directory as agent.hcl
unless a path is specified as an argument.
Example
Before generating a configuration file, let's insert a secret foo
:
Generate an agent configuration file which will reference secret/foo
:
Expected output:
This will produce my-config.hcl
file in the current directory with contents
similar to the following:
Usage
The following flags are available in addition to the standard set of flags included in all commands.
type
(string: <required>)
- The type of configuration file to generate; currently, onlyenv-template
is supported.path
(string: "")
- Path to a kv-v1 or kv-v2 secret (e.g.secret/data/foo
,kv-v2/my-app/*
); multiple secrets and tail*
wildcards are allowed.-exec
(string: "env")
- The command to execute in agent process supervisor mode.
Tutorial
Refer to the Vault Agent - secrets as environment variables tutorial for an end-to-end example.