Multiple Inheritance
The Multiple Inheritance pattern allows a component to inherit from multiple abstract base components, combining their configurations. This lets you compose components from reusable building blocks.
Use-casesβ
Use Multiple Inheritance when:
-
You have reusable configuration "traits" that apply to multiple components
-
You want to compose configuration from independent concerns (e.g., logging + monitoring + security)
-
Different teams own different aspects of component configuration
How It Worksβ
A component lists multiple base components in metadata.inherits. Configuration is merged in orderβlater entries override earlier ones:
metadata:
inherits:
- base/defaults # Applied first
- base/logging # Applied second, overrides conflicts
- base/production # Applied last, highest precedence
Example: Composing from Traitsβ
Define abstract base components that represent different configuration concerns:
stacks/catalog/base/defaults.yaml
stacks/catalog/base/logging.yaml
stacks/catalog/base/production.yaml
Now compose a concrete component by inheriting from multiple bases:
stacks/deploy/prod.yaml
The resulting rds component has:
# From base/defaults
enabled: true
tags:
managed_by: atmos
environment: production # Merged from base/production
# From base/logging
logging_enabled: true
log_retention_days: 30
# From base/production
multi_az: true
deletion_protection: true
# From inline vars
name: my-database
instance_class: db.r6g.large
Example: Environment + Size Traitsβ
Combine environment settings with sizing presets:
stacks/catalog/size/small.yaml
stacks/catalog/size/large.yaml
stacks/catalog/env/dev.yaml
stacks/catalog/env/prod.yaml
Compose different combinations:
stacks/deploy/dev.yaml
stacks/deploy/prod.yaml
Merge Behaviorβ
When the same key exists in multiple base components:
| Data Type | Behavior |
|---|---|
| Scalars (strings, numbers, bools) | Later value wins |
| Maps/Objects | Deep merged, later values override |
| Lists/Arrays | Later list replaces entirely |
Example with maps:
# base/defaults
tags:
managed_by: atmos
team: platform
# base/production
tags:
environment: production
# Result (deep merged)
tags:
managed_by: atmos # from defaults
team: platform # from defaults
environment: production # from production
Related Patternsβ
- Abstract Component - Create non-deployable base components
- Component Inheritance - Single inheritance basics
- Component Catalog - Organize base components