Configure Dependencies Between Components
Atmos supports configuring the relationships between components in the same or different stacks. You can define dependencies between components to ensure that components are deployed in the correct order.
Before deploying components, it's important to consider the dependencies between components. For example, a database component might depend on a network component. When this happens, it's important to ensure that the network component is deployed before the database component.
Support for dependencies is reliant on the integration used and not all integrations support dependencies.
For example, GitHub Actions do not support dependency order applies, while Spacelift does.
You can define component dependencies by using the settings.depends_on section. The section used to define all the Atmos components (in
the same or different stacks) that the current component depends on.
The settings.depends_on section is a map of objects. The map keys are just the descriptions of dependencies and can be strings or numbers. Provide meaningful descriptions or numbering so that people can understand what the dependencies are about.
Why is settings.depends_on a map instead of a list?
We originally implemented settings.depends_on as a list. However, since it’s not clear how lists should be
deep-merged, so we decided to convert it to a map instead. In this map, the keys are lexicographically ordered, and
based on that order, the dependencies are managed.
Each object in the settings.depends_on section has the following schema:
- file (optional)
 - A file on the local filesystem that the current component depends on
 - folder (optional)
 - A folder on the local filesystem that the current component depends on
 - component (required if 
fileorfolderis not specified) - an Atmos component that the current component depends on
 - stack (optional)
 - The Atmos stack where the 
componentis provisioned - namespace (optional)
 - The 
namespacewhere thecomponentis provisioned - tenant (optional)
 - The 
tenantwhere thecomponentis provisioned - environment (optional)
 - The 
environmentwhere thecomponentis provisioned - stage (optional)
 - The 
stagewhere thecomponentis provisioned 
One of component, file or folder is required.
If component is specified, you can provide the other context variables to define an Atmos stack other than the current stack.
For example, you can specify:
stackif thecomponentis from a different Atmos stacknamespaceif thecomponentis from a different Organizationtenantif thecomponentis from a different Organizational Unitenvironmentif thecomponentis from a different regionstageif thecomponentis from a different accounttenant,environmentandstageif the component is from a different Atmos stack (e.g.tenant1-ue2-dev)
If stack is specified, it's processed first and the namespace, tenant, environment and stage attributes are ignored.
You can use Atmos Stack Manifest Templating in depends_on.
Atmos processes the templates first, and then detects all the dependencies, allowing you to provide the parameters to
depends_on dynamically.
Examples
In the following example, we specify that the component1 component depends on the following:
- The 
component2component in the same Atmos stack ascomponent1 - The 
component3component from theprodstage - The 
component4component from thetenant1tenant,ue2environment andstagingstage (tenant1-ue2-stagingAtmos stack) - The 
component5component from thetenant1-ue2-prodAtmos stack - The 
component6component from the same Atmos stack ascomponent1 - The 
component7component from the same tenant and stage ascomponent1, butuw2environment 
tenant1-ue1-dev.yaml
Specifying stack
The stack attribute has higher precedence than the other context variables.
If stack is specified, the namespace, tenant, environment and stage attributes are ignored.
As you can see in the examples above, we can use Atmos Stack Manifest Templating in the stack attribute to dynamically specify the stack.
This is useful when configuring
stacks.name_template in atmos.yaml to define and refer to stacks.
In this case, you can't use the context variables namespace, tenant, environment and stage in depends_on.
For example, in atmos.yaml, we specify stacks.name_template to define Atmos stacks, and enable templating:
atmos.yaml
In this example, stacks are defined by the settings.context section, not vars.
In the tenant1-uw2-dev Atmos stack, we can use the following depends_on configuration to define the component dependencies:
tenant1-uw2-dev.yaml
Execute the following Atmos commands to see the component dependencies:
For more information, refer to atmos describe dependents
and atmos describe affected CLI commands.