Skip to content

stacks

The stacks key defines named groups of dirspaces (directory + workspace combinations) with shared configuration, variables, and orchestration rules.

Default Configuration

stacks:
names: {}

Keys

stacks

KeyTypeDescription
namesMapA map of stack names to their configurations

stacks.names.<name>

Each named stack can be either a regular stack (with tag_query) or a nested stack (with stacks).

Regular Stack Configuration

KeyTypeDescription
tag_queryStringRequired. Tag query expression to match dirspaces for this stack
variablesMapOptional. Key-value pairs of variables accessible in workflows
rulesObjectOptional. Orchestration rules for this stack

Nested Stack Configuration

KeyTypeDescription
stacksListRequired. List of stack names to include in this nested stack
variablesMapOptional. Key-value pairs of variables accessible in workflows
rulesObjectOptional. Orchestration rules for this stack

stacks.names.<name>.rules

KeyTypeDescription
plan_afterListStack names that must be applied before this stack can plan
apply_afterListStack names that must be applied before this stack can apply
modified_byListStack names that, when modified, trigger this stack as modified
auto_applyBooleanWhether to automatically apply this stack after successful plan

Examples

Basic Environment Stacks

stacks:
names:
development:
tag_query: 'development'
variables:
environment: dev
aws_account: "111111111111"
rules:
auto_apply: true
staging:
tag_query: 'staging'
variables:
environment: staging
aws_account: "222222222222"
rules:
apply_after:
- development
production:
tag_query: 'production'
variables:
environment: prod
aws_account: "333333333333"
rules:
apply_after:
- staging

Layered Infrastructure

stacks:
names:
network:
tag_query: 'network'
data:
tag_query: 'database'
rules:
plan_after:
- network
compute:
tag_query: 'compute'
rules:
plan_after:
- network
application:
tag_query: 'application'
rules:
plan_after:
- data
- compute

Nested Stacks

stacks:
names:
us-east-1:
tag_query: 'us-east-1'
variables:
region: us-east-1
us-west-2:
tag_query: 'us-west-2'
variables:
region: us-west-2
all-regions:
stacks:
- us-east-1
- us-west-2
rules:
auto_apply: true

Modified By Rules

stacks:
names:
shared:
tag_query: 'dir:shared/*'
base:
tag_query: 'dir:base/*'
rules:
modified_by:
- shared
# plan_after is implicitly set to [shared]
services:
tag_query: 'dir:services/*'
rules:
modified_by:
- base
plan_after:
- shared
# Explicit plan_after, so no implicit construction

Using Stack Variables

stacks:
names:
production:
tag_query: 'production'
variables:
tf_version: "1.5.7"
region: "us-east-1"
workflows:
- tag_query: ''
engine:
tf_version: '${tf_version}'
plan:
- type: init
extra_args: ['-backend-config=region=${region}']
- type: plan

Integration with Access Control

stacks:
names:
production:
tag_query: 'production'
access_control:
policies:
- tag_query: 'stack_name:production'
plan: ['*']
apply: ['team:sre']