Override Configurations
Atmos supports the ability to override the behavior of imports when the order of
deep-merging interferes with what you want to express. Use the overrides section in Atmos stack manifests.
You can override the following sections in the component(s) configuration:
commandenvhooksproviderssettingsvars
The overrides section can be used in the global scope or in the Terraform and Helmfile scopes.
The Component Overrides Design Pattern goes into further details on how to use this effectively.
Overrides Schema
The overrides section schema at the global scope is as follows:
overrides:
# Override the ENV variables for the components in the current stack manifest and all its imports
env: {}
# Override the hooks for the components in the current stack manifest and all its imports
hooks: {}
# Override the settings for the components in the current stack manifest and all its imports
settings: {}
# Override the variables for the components in the current stack manifest and all its imports
vars: {}
# Override the providers configuration section for the Terraform components in the current stack manifest and all its imports
# Note: this applies only to Terraform components in the `terraform.providers` and `component.terraform.<component>.providers` sections
providers: {}
# Override the command to execute for the components in the current stack manifest and all its imports
command: "<command to execute>"
The overrides section schemas at the Terraform and Helmfile levels are as follows:
terraform:
overrides:
env: {}
hooks: {}
settings: {}
vars: {}
providers: {}
command: "<command to execute>"
helmfile:
overrides:
env: {}
settings: {}
vars: {}
command: "<command to execute>"
You can include the overrides, terraform.overrides and helmfile.overrides sections in any Atmos stack manifest at any level of inheritance.
The scope of the override configuration is limited to all the Atmos components defined within the manifest and all its imports up until that point.
In other words, the overrides configuration defined within a stack manifest does not affect any other components defined in different stack manifests for the same top-level stack.
Refer to Atmos Component Inheritance for more information on all types of component inheritance supported by Atmos
Use-cases
Overrides for Teams
The overrides pattern is used to override the components only in a particular Atmos stack manifest and all the imported
manifests. This is different from the other configuration sections (e.g. vars, settings, env). If we define a vars, settings or env
section at the global, Terraform or Helmfile levels, all the components in the top-level stack will get the updated configurations. On
the other hand, if we define an overrides section in a stack manifest, only the components directly defined in the manifest and its imports will get
the overridden values, not all the components in the top-level Atmos stack.
This is especially useful when you have Atmos stack manifests split per Teams. Each Team manages a set of components, and you need to define a common configuration (or override the existing one) for the components that only a particular Team manages.
For example, we have two Teams: devops and testing.
The devops Team manifest is defined in stacks/teams/devops.yaml:
stacks/teams/devops.yaml
The testing Team manifest is defined in stacks/teams/testing.yaml:
stacks/teams/testing.yaml
We can import the two manifests into a top-level stack manifest, e.g. tenant1/dev/us-west-2.yaml:
stacks/orgs/cp/tenant1/dev/us-west-2.yaml
Suppose that we want to change some variables in the vars and env sections and some config in the settings section for all the components that the testing Team manages, but we don't want to affect any components that the devops Team manages.
If we added a global or Terraform level vars, env or settings sections to the top-level manifest stacks/orgs/cp/tenant1/dev/us-west-2.yaml or to the Team manifest stacks/teams/testing.yaml, then all the components in the tenant1/dev/us-west-2 top-level stack would be modified, including those managed by the devops Team.
To solve this, we could individually modify the vars, env and settings sections in all the components managed by the testing Team, but the entire configuration would not be DRY and reusable. That's where the overrides pattern comes into play. To make the configuration DRY and configured only in one place, use the overrides section.
For example, we want to override some values in the env, vars and settings sections for all the components managed by the testing Team:
stacks/teams/testing.yaml
In the manifest above, we configure the following:
-
The global
overridessection to override theTEST_ENV_VAR1ENV variable in theenvsection. All the Terraform and Helmfile components managed by thetestingTeam will get the ENV vars updated totest-env-var1-overridden. -
The Terraform-level
terraform.overridessection to override some Spacelift configuration in thesettingssection, a variable in thevarssection, and thetofucommand to execute instead ofterraformin thecommandsection. All the Terraform components managed by thetestingTeam will be affected by the new values (but not the Helmfile components). The Terraformoverridesare deep-merged with the globaloverridesand takes higher priority (it will override the same keys from the globaloverrides). -
The Helmfile-level
helmfile.overridessection to override an ENV variable in theenvsection. All the Helmfile components managed by thetestingTeam will get the new ENV variable value (but not the Terraform components). The Helmfileoverridesare deep-merged with the globaloverridesand takes higher priority (it will override the same keys from the globaloverrides).
To confirm that the components managed by the testing Team get the new values from the overrides sections, execute the following
commands:
atmos describe component test/test-component -s tenant1-uw2-dev
atmos describe component test/test-component-override -s tenant1-uw2-dev
You should see the following output:
To confirm that the components managed by the devops Team are not affected by the overrides for the testing Team, execute the following
command:
The top-level-component1 component managed by the devops Team does not get affected by the overrides sections for the testing Team,
and the sections vars, env, settings and command are not updated with the values from the overrides configuration.
Importing the Overrides
To make the overrides configuration DRY and reusable, you can place the overrides sections into a separate stack manifest,
and then import it into other stacks.
For example:
Define the overrides sections in a separate manifest stacks/teams/testing-overrides.yaml:
stacks/teams/testing-overrides.yaml
Import the stacks/teams/testing-overrides.yaml manifest into the stack stacks/teams/testing.yaml:
stacks/teams/testing.yaml
-
The order of the imports is important. The
overridesinteams/testing-overrideswill affect all the components in this stack manifest and all the components that are imported after theoverridesfromteams/testing-overrides. In other words, theoverridesinteams/testing-overrideswill be applied to thecatalog/terraform/test-componentandcatalog/terraform/test-component-overridecomponents, but not tocatalog/terraform/test-component-2 -
On the other hand, the
overridesdefined in this stack manifeststacks/teams/testing.yamlwill be applied to all components defined inline instacks/teams/testing.yamland all the imported components, includingcatalog/terraform/test-component-2 -
The
overridesdefined inline in the stack manifeststacks/teams/testing.yamltake precedence over theoverridesimported fromteams/testing-overrides(they will override the same values defined inteams/testing-overrides)
Refer to atmos describe component CLI command for more details