A simple buildkite plugin to map a Vault secret to a Step environment variable
vault and jq are expected to be installed on your Buildkite worker.
Add the following to your pipeline.yml:
steps:
- command: "<your-command>"
plugins:
- elastic/vault-secrets#v0.1.0:
path: "secret/ci/elastic-<repo-name>/<secret-name>"
field: "<secret-field-name>" # OPTIONAL
env_var: "<environment-variable-mapping-secret>" # OPTIONAL
path_depth: "2" # OPTIONALfieldspecifies the exact Vault secret field to retrieve. Whenfieldisn't defined, the entire secret is retrieved in json formatenv_varspecifies the name of the environment variable that will contain the secret. Whenenv_varis not specified, the name of the environment variable will be generated using this scheme:<UPPERCASE_SECRET_NAME>[_<UPPERCASE_FIELD_NAME>]_SECRET. Note that if you do specify anenv_var, you should use one of the patterns that will ensure Buildkite will redact the secret, see the docs for details.path_depthspecifies the number of elements of the path to use in the variable name whenenv_varisn't defined. When not defined the default value is2
Please refer to the test pipeline and scripts in ths .buildkite directory as examples.