Component Overrides
The Component Overrides pattern lets you apply configuration to a specific group of components without affecting other components in the same stack.
The Problem
When you set vars at the stack level, it applies to every component in the final merged stack:
import:
- teams/platform # imports: vpc, eks, rds
- teams/security # imports: waf, security-groups
vars:
environment: prod
# This tag applies to ALL components (vpc, eks, rds, waf, security-groups)
tags:
Team: Platform
But what if the Platform team and Security team each want their own Team tag? You can't use regular vars because it applies globally.
The Solution: Overrides
The overrides section is scoped to the current file and its imports. It doesn't leak into sibling imports or get inherited by files that import this one.
Overrides are file-scoped and don't get inherited. They only apply to components visible from that file's import tree.
stacks/teams/platform.yaml
stacks/teams/security.yaml
stacks/deploy/prod.yaml
Now each team's components get their own Team tag, even though they're all in the same final stack.
When to Use Overrides
| Scenario | Use vars | Use overrides |
|---|---|---|
| Setting values for ALL components | ✓ | |
| Setting values for a SUBSET of components | ✓ | |
| Team-specific configuration | ✓ | |
| Layer-specific settings (network, data, compute) | ✓ |
Overrides vs Vars
| Aspect | vars | overrides |
|---|---|---|
| Scope | Final merged stack (global) | Current file + its imports only |
| Inheritance | Gets inherited by importing files | Does NOT get inherited |
| Visibility | Affects ALL components | Only affects components "visible" from this file |
Think of it this way:
vars= "Apply this to the final result"overrides= "Apply this only to what I can see from here"
platform.yaml
├── imports: vpc, eks, rds
├── overrides: Team=Platform ← only sees vpc, eks, rds
│
security.yaml
├── imports: waf, firewall
├── overrides: Team=Security ← only sees waf, firewall
│
prod.yaml
├── imports: platform.yaml, security.yaml
├── vars: env=prod ← sees ALL components (vpc, eks, rds, waf, firewall)
Example: Layer-Based Overrides
When using Layered Stack Configuration, overrides let each layer tag its components:
stacks/layers/network.yaml
stacks/layers/data.yaml
What You Can Override
The overrides section supports:
vars- Input variablesenv- Environment variablessettings- Component settingscommand- The executable to use (e.g.,tofuinstead ofterraform)providers- Terraform provider configurationhooks- Lifecycle hooks
terraform:
overrides:
vars:
tags:
Team: Platform
settings:
spacelift:
autodeploy: true
command: tofu # Use OpenTofu for these components
Related Patterns
- Layered Stack Configuration - Group components by function
- Component Catalog - Define component defaults
References
- Overrides Configuration - Complete reference documentation