Dependencies
Blocks can declare dependencies on services provided by other blocks using
consumes. Stackie automatically wires the consuming block to the correct
provider and port at startup.
Declaring a Dependency
In your stack file, add a consumes entry that references either a port
type or a specific block name:
my-project:
blocks:
stackie.postgres:
serves:
PORT:
port: 5432
type: db
my-api:
consumes:
DATABASE:
port_type: db
Stackie resolves DATABASE to the postgres block’s port and injects
${consumes.DATABASE.HOST} and ${consumes.DATABASE.PORT} into the
consuming block’s environment.
Explicit Block Override
When multiple blocks serve the same port type, specify which one to use:
my-project:
blocks:
primary-pg:
serves:
PORT: { port: 5432, type: db }
replica-pg:
serves:
PORT: { port: 5433, type: db }
my-api:
consumes:
DATABASE:
block_override: primary-pg
Resolution Errors
Stackie reports a clear error when:
- No match — no block in the stack serves the requested port type.
- Ambiguous match — multiple blocks serve the same port type and no
block_overridewas provided. - Missing block — a
block_overridereferences a block name that doesn’t exist in the stack.