!labels.values
The !labels.values YAML function returns the values of the current component's own
metadata.labels as a []string, ordered by key — useful when a module or script wants a flat
list of label values instead of the full map.
Availability and evaluation
Supported locations:
- Resolved stack values: after inheritance, merging, and component template processing.
Automatic evaluation requires native YAML tags from edition 2026-10-20, including unpinned projects. Quoted function strings remain literal; earlier editions retain legacy string-form behavior.
See YAML function scope for field restrictions, import timing, and native tags versus quoted strings.
Usage
The !labels.values function takes no parameters:
components:
terraform:
vpc:
metadata:
labels:
Namespace: eg
Environment: prod
cost-center: platform
vars:
label_values: !labels.values
Arguments
This function takes no arguments. It reads metadata.labels from the component it's used on.
How It Works
!labels.values reads the component's metadata.labels map and returns its values as a
[]string, ordered by key for deterministic output (Go map iteration order is randomized, so
sorting by key matters for reproducible plans). If metadata.labels is unset, !labels.values
returns an empty list rather than an error.
Examples
Related Functions
- !labels - Get the current component's own
metadata.labelsas a map - !labels.keys - Get the current component's
metadata.labelskeys - !tags - Get the current component's own
metadata.tagsas a list