Skip to content
Unified Defense StackUnified Defense Stack
You're viewing unreleased documentation from main. Go to the latest release

Next HCL helper functions

Next registers file() and sensitive() as HCL helper functions. file() is available in file-backed bundle.uds.hcl, defaults.uds.hcl, and config.uds.hcl inputs. sensitive() is available in evaluated expressions throughout bundle.uds.hcl and config.uds.hcl, in variables in defaults.uds.hcl, and in deploy --set expressions. base64encode() and base64decode() are not available. These HCL functions do not extend Go text/template functions used in package values files.

FunctionSupported context
file(path)Expressions in file-backed bundle.uds.hcl; variables in file-backed defaults.uds.hcl; string-valued expressions throughout file-backed config.uds.hcl, including options and trust fields.
sensitive(value)Evaluated expressions in bundle.uds.hcl and config.uds.hcl; variables in defaults.uds.hcl; deploy --set expressions.

file(path) reads a regular UTF-8 file and returns its contents as a string. The argument must be a string. Relative paths resolve from the directory containing the HCL file; absolute paths are used as-is. The CLI process must be able to access the path.

Use it in bundle expressions, including locals, metadata, and package fields. In config.uds.hcl, a trust field can load a public key. The example needs keys/cosign.pub under the directory containing the config file:

config.uds.hcl
signature_verification {
public_key = file("keys/cosign.pub")
}

The path must exist and identify a regular file containing valid UTF-8. A missing or unreadable file, directory, invalid UTF-8, or invalid argument makes HCL evaluation fail. file() is unavailable when parsing in-memory bundle or defaults bytes because those inputs have no source directory.

sensitive(value) accepts a value, returns it unchanged, and marks it sensitive. Use it in any evaluated expression in bundle.uds.hcl or config.uds.hcl, inside variables in defaults.uds.hcl, or in a deploy --set expression:

config.uds.hcl
variables = {
password = sensitive(file("secrets/password.txt"))
registry = { token = sensitive("replace-me") }
}

For the file-backed example, create secrets/password.txt beside config.uds.hcl.

A mark anywhere inside a top-level variable marks that entire variable. Sensitivity metadata survives defaults, config, and --set merging.

Sensitivity is metadata, not encryption. The value passed to templates and Zarf is unchanged. Marked values are omitted from CLI-managed deployment diagnostics and errors, and exact known values are redacted from standard logs. Redaction can miss transformed or partial values, or redact matching text in unrelated logs; direct stdout/stderr and explicit loggers that bypass the standard logger are not covered. Materializing sensitive(file(...)) embeds the file contents as plaintext while preserving the sensitivity mark.

In defaults.uds.hcl, sensitive() is valid only inside variables. In bundle.uds.hcl and config.uds.hcl, it is available in evaluated expressions, including structured config fields such as options and signature_verification.