Skip to main content
A stack is a collection of resources you choose to manage together. It is formae’s unit of lifecycle: reconciling a stack is what lets formae remove resources that are no longer declared, and destroying a stack tears down everything in it. A stack is not a boundary for references. Resources in one stack can reference resources in another through resolvables. The stack is about lifecycle, not about isolating dependencies. You never create a stack up front. When you apply a forma, formae looks for a stack by label and creates it if it doesn’t exist yet:
Every resource in that forma is assigned to the stack automatically.
A stack cleans up after itself. When its last resource is destroyed, formae deletes the empty stack for you; you never remove one by hand.

One stack per resource

Each resource belongs to exactly one stack. A single owner is what keeps lifecycle and state tracking unambiguous, and it stops two stacks from fighting over the same resource. Decide which stack a resource lives in when you design your infrastructure.

Designing stack boundaries

Because the stack is the unit of lifecycle, its boundaries decide what gets deployed, reconciled, and destroyed together. Common ways to draw them:
  • By environment: dev, staging, production
  • By application or service: user-service, payments, analytics
  • By layer: networking, databases, compute
Smaller stacks give you finer-grained control; larger stacks keep related resources together.
Policies attach at the stack level. A TTL or auto-reconcile policy governs the whole stack, so a resource inherits whatever policy its stack carries. Factor this into where you draw boundaries: if two resources need different lifecycle policies, they belong in different stacks. (Resource-level policies are coming, which will relax this.)

Version control

formae tracks resources and their lifecycle at the stack level. You can extract any managed stack in your preferred format for version control, backup, or reuse in another environment.

See also

  • Forma: the declaration that creates and updates stacks.
  • Target: where a stack’s resources are applied.
  • Apply modes: how reconcile uses stack boundaries to decide what to remove.
  • Policy: TTL and auto-reconcile policies, which are scoped to a stack.