YQ Default Values Now Work Reliably in YAML Functions
· 3 min read
We've fixed an issue where YQ default values (using the // fallback operator) in !terraform.state and !terraform.output YAML functions were not being evaluated when components weren't provisioned or outputs didn't exist.
What Changed
YQ expressions with default values now work correctly in all scenarios:
# This now works reliably when vpc component isn't provisioned
vars:
vpc_id: !terraform.output vpc {{ .stack }} .vpc_id // "default-vpc"
subnets: !terraform.state vpc {{ .stack }} .subnets // ["subnet-1", "subnet-2"]
The Problem
Previously, when a terraform component wasn't provisioned or an output didn't exist, the YAML function wrappers would return nil or exit before the YQ pipeline could evaluate default expressions. This caused sporadic failures where users expected the YQ // operator to provide fallback values.
The issue manifested as:
- Stack configurations failing when referencing unprovisioned components
- Inconsistent behavior depending on component state
- No way to gracefully handle missing outputs with defaults
