Advanced declarations
Dependency declarations use # or // line comments in the root module’s
.tf and .tofu files. A comment with an invalid field or template declares
nothing, not even part of a dependency. The run log lists every one. The stack
page and Explore Insights show how many the stack’s latest deployment
ignored; expand them to read each file:line and message. The count is part of
the stack’s dependency metadata, so rebuilding metadata recomputes it.
from_stack
The required ID of the stack this stack depends on:
# gantrycd:dependency: from_stack=network
Use this field or from_stack_tpl, not both.
from_stack_tpl
Build the dependency stack ID from the current stack:
# gantrycd:dependency: from_stack_tpl="network-{{ .stack.Labels.environment }}"
Data available to templates
Each _tpl field can read one object, .stack, with:
.stack.ID— the current stack ID.stack.Name— the current stack name.stack.Labels— the current stack’s label map.stack.Labels.<key>— one label value, such as.stack.Labels.environment
Use index .stack.Labels "team-name" when a label key cannot be written with
dot notation. A missing dot-notation key or an empty final result rejects the
declaration.
Functions available to templates
GantryCD adds these string helpers:
- Trim:
trim,trimAll,trimPrefix,trimSuffix,nospace - Case:
upper,lower,title,snakecase,camelcase,kebabcase - Change:
replace,substr,trunc - Split and join:
split,splitList,join - Check:
contains,hasPrefix,hasSuffix - Fallback:
default,coalesce - Quote:
quote,squote
Standard Go template features are also available:
- Conditions and loops:
if,else,with,range - Logic:
and,or,not - Compare:
eq,ne,lt,le,gt,ge - Read values:
index,slice,len - Call and print:
call,print,printf,println - Escape:
html,js,urlquery
Environment, time, random, UUID, crypto, and repeat functions are not
available.
from_resource
The optional resource or output in the dependency stack:
# gantrycd:dependency: from_stack=network from_resource=output.vpc_id
Without it, the declaration covers the whole dependency stack. With it, a trigger applies only when that address or something inside it changes.
from_resource_tpl
The template form of from_resource:
# gantrycd:dependency: from_stack=network from_resource_tpl="module.vpc_{{ .stack.Labels.environment }}"
It has the same template data and string helpers as from_stack_tpl. Use one
form of from_resource, not both.
resource
The optional resource in the current stack that depends on the target:
# gantrycd:dependency: from_stack=network resource=module.application
When omitted, the comment uses the next resource, data or module block
below it, skipping blank lines and other comments. If no such block follows, the
whole current stack is the dependent. A trailing comment on a block header is
read the same way, so it names the following block, not its own.
scope
State the dependent side instead of leaving it to placement:
# gantrycd:dependency: from_stack=network scope=stack
stack is the only value, and it is mutually exclusive with resource. It does
not touch the other side: pair it with from_resource when the whole stack
depends on one resource of the target.
stack
Apply a shared declaration only when the current stack has this exact ID:
# gantrycd:dependency: from_stack=network stack=application-prod
Use this field or stack_regex, not both.
stack_regex
Apply a shared declaration when the current stack ID matches a regular expression:
# gantrycd:dependency: from_stack=network stack_regex="^application-(dev|prod)$"
trigger
Choose manual, always, never, or hidden. The default is manual, and
there is no template form:
# gantrycd:dependency: from_stack=network trigger=always
See Trigger policies for how each value behaves.