Component Catalog
The Component Catalog is a powerful pattern for organizing and managing the configuration of components across multiple stacks, enabling easy reuse of default configurations. Use this pattern to maintain a DRY (Don't Repeat Yourself) configuration approach, ensuring consistent and efficient deployments across various environments and regions.
Use-cases
Use the Component Catalog pattern when:
-
You have many components that are provisioned in multiple stacks (many OUs, accounts, regions) with different configurations for each stack
-
You need to make the components' default configurations reusable across different stacks
-
You want the component catalog folders structures to mirror the Terraform components folder structure to make it easy to find and manage
-
You want to keep the configurations DRY
Benefits
The Component Catalog pattern provides the following benefits:
-
The defaults for the components are defined in just one place (in the catalog) making the entire configuration DRY
-
The defaults for the components are reusable across many environments by using hierarchical imports
-
It's easy to add a new manifest in the component's catalog to enable a new component's feature, then import the manifest into the corresponding stacks where the feature is required
Design Pattern
The Component Catalog pattern prescribes the following:
-
For each Terraform component, create a folder with the same name in
stacks/catalog
to make it symmetrical and easy to find. For example, thestacks/catalog/vpc
folder should mirror thecomponents/terraform/vpc
folder. -
In the component's catalog folder, create
defaults.yaml
manifest with all the default values for the component (the defaults that can be reused across multiple environments). Define all the required Atmos sections, e.g.metadata
,settings
,vars
,env
. -
In the component's catalog folder, add other manifests for different combinations of component configurations. We refer to them as archetype manifests. Each archetype can import the
defaults.yaml
file to reuse the default values and make the entire config DRY. For example:stacks/catalog/vpc/disabled.yaml
- component manifest with the component disabled (vars.enabled: false
)stacks/catalog/vpc/dev.yaml
- component manifest with the settings related to thedev
accountstacks/catalog/vpc/staging.yaml
- component manifest with the settings related to thestaging
accountstacks/catalog/vpc/prod.yaml
- component manifest with the settings related to theprod
accountstacks/catalog/vpc/ue2.yaml
- component manifest with the settings forus-east-2
regionstacks/catalog/vpc/uw2.yaml
- component manifest with the settings forus-west-2
regionstacks/catalog/vpc/feature-1.yaml
- component manifest withfeature-1
setting enabled
Having the dev
, staging
, prod
, ue2
and uw2
manifests in the component's catalog makes the most sense for multi-org, multi-OU and/or
multi-region architectures, such that there will be multiple dev/staging/prod or region configurations, which get imported into multiple Org/OU
top-level stack manifests.
-
After we have defined the manifests for different use-cases, we import them into different top-level stacks depending on a particular use-case. For example:
- import the
catalog/vpc/ue2.yaml
manifest into thestacks/mixins/region/us-east-2.yaml
mixin since we need thevpc
component with theus-east-2
region-related config provisioned in the region - import the
catalog/vpc/uw2.yaml
manifest into thestacks/mixins/region/us-west-2.yaml
mixin since we need thevpc
component with theus-west-2
region-related config provisioned in the region - import the
catalog/vpc/dev.yaml
manifest into thestacks/orgs/acme/plat/dev/us-east-2.yaml
top-level stack since we need thevpc
component with the dev-related config provisioned in the stack - import the
catalog/vpc/prod.yaml
manifest into thestacks/orgs/acme/plat/prod/us-east-2.yaml
top-level stack since we need thevpc
component with the prod-related config provisioned in the stack - import the
catalog/vpc/staging.yaml
manifest into thestacks/orgs/acme/plat/staging/us-east-2.yaml
top-level stack since we need thevpc
component with the dev-related config provisioned in the stack - import the
catalog/vpc/disabled.yaml
manifest into a stack where we want thevpc
component to be disabled (e.g. temporarily until it's needed) - etc.
- import the