Component Dependencies
The dependencies.components section defines relationships between components, ensuring they are deployed in the correct order. Use it to declare which components must be applied before others.
Use Cases
- Execution Order: Ensure VPC is created before subnets
- CI/CD Orchestration: Spacelift and other integrations use dependencies to order stack runs
- Impact Analysis: The
atmos describe affectedcommand uses dependencies to find impacted components - File/Folder Watching: Trigger component redeployment when external files change
Configuration
The dependencies.components section is a list of dependency objects.
Schema
- component (optional)
- The component instance name as defined in the stack (e.g.,
vpc,subnet,tgw/hub). This is the name undercomponents.<kind>.<name>, not the Terraform module path. Required for component dependencies. - stack (optional)
- The Atmos stack name where the component is provisioned (e.g.,
tenant1-ue2-prod). If omitted, the component is assumed to be in the same stack. Use templates to construct stack names dynamically. - kind (optional)
- The dependency type:
terraform,helmfile,packer,file,folder, or a registered plugin type. Defaults to the declaring component's type for component dependencies. Usefileorfolderfor path-based dependencies. - path (optional)
- The file or folder path for path-based dependencies. Required when
kindisfileorfolder. Changes to files at this path mark the component as affected.
For component dependencies, component is required. For path dependencies (kind: file or kind: folder), path is required.
Examples
Same-Stack Dependency
The simplest case: a component depends on another component in the same stack.
stacks/catalog/network.yaml
Cross-Stack Dependencies
Use the stack field or templates to depend on components in different stacks.
stacks/orgs/acme/plat/dev/us-east-1.yaml
File and Folder Dependencies
Trigger describe affected when external files or folders change using kind and path.
stacks/catalog/lambda.yaml
Cross-Type Dependencies
Depend on components of a different type using the kind field.
stacks/catalog/app.yaml
Merge Behavior
dependencies.components uses append merge behavior: child stacks add their dependencies to parent dependencies.
stacks/catalog/base.yaml
stacks/orgs/acme/plat/prod/us-east-1.yaml
Integration with atmos describe affected
The dependencies.components section is used by atmos describe affected to determine which components are impacted by changes.
How It Works
When you run atmos describe affected:
- Atmos compares the current branch to the target branch (e.g.,
main) - It identifies changed files (stack configs, component code)
- It checks
dependencies.componentsfor file/folder dependencies - Components with changed dependencies are marked as "affected"
Example: File Dependency
stacks/catalog/lambda.yaml
# If src/lambda/handler/index.js changed:
atmos describe affected --ref refs/heads/main
# Output includes my-lambda because its dependency folder changed
Example: Component Dependency
If component A depends on component B, and component B is affected by changes, component A is also marked as affected (transitive dependency).
Viewing Dependencies
List Dependents
Find all components that depend on a specific component:
List Affected Components
Find all components affected by changes in a branch:
Best Practices
- Declare All Dependencies - Be explicit about dependencies, even if the order seems obvious
- Avoid Circular Dependencies - Component A cannot depend on B if B depends on A
- Use Templates for Cross-Stack - Use
{{ .vars.tenant }}-{{ .vars.environment }}-{{ .vars.stage }}instead of hardcoded stack names - Combine with YAML Functions - Use
!terraform.outputto pass data between dependent components - Test with
describe affected- Verify your dependencies work correctly in CI/CD
Migration from settings.depends_on
If you're using the legacy settings.depends_on format:
Old format (deprecated)
New format (recommended)
Key Differences
| Feature | settings.depends_on | dependencies.components |
|---|---|---|
| Format | Map with numeric keys | List |
| Merge behavior | Deep merge (complex) | Append (simple) |
| Location | Under settings | Under dependencies |
| Cross-stack | namespace, tenant, environment, stage fields | stack field only (use templates) |
| Cross-type | Not supported | Use kind field (terraform, helmfile, packer, etc.) |
| File/folder deps | file and folder fields | kind: file or kind: folder with path |
Both formats continue to work. The new format is recommended for new configurations.
Related Documentation
- Dependencies Overview - Tool and component dependencies overview
- describe dependents - List components that depend on a component
- describe affected - List components affected by changes
- YAML Functions - Using
!terraform.outputfor cross-component data - Spacelift Integration - CI/CD integration with dependency ordering