Skip to content
GantryCD

Advanced declarations

Dependency declarations use # or // line comments in the root module’s .tf and .tofu files. Invalid fields or templates are reported in the run log and do not create a partial dependency.

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 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, a comment directly above a resource, data, or module block uses that block. If there is no such block, the whole current stack is the dependent.

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, or never. 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.