README.md3.3 KB
View on GitHubCustom Components Example
This example demonstrates how to define custom component types in Atmos using custom commands.
Overview
Custom component types allow you to extend Atmos beyond the built-in component types. This example defines an example type and accesses its configuration from stack files via Go templates.
For implementation logic with conditions, loops, and reusable functions, use
Atmos scripting (Starlark). A type: script step
with interpreter: starlark reads the resolved configuration through
ctx.component. See the Starlark custom-component walkthrough.
Structure
examples/custom-components/
├── atmos.yaml # Atmos configuration with custom command
├── components/
│ └── example/
│ └── deploy-app/
│ └── deploy.sh # Example script (not executed)
└── stacks/
├── catalog/
│ └── example/
│ └── deploy-app.yaml # Base component configuration
└── deploy/
└── dev.yaml # Stack with overrides
Usage
-
Inspect the custom component type configuration:
atmos describe config --format=yaml --query .components.example -
Run the custom command:
cd examples/custom-componentsatmos example deploy-app --stack dev -
Expected output:
Component: deploy-appStack: devApp: myappVersion: 1.0.0Replicas: 1Env: deploying v1.0.0 to us-east-1
How It Works
-
Custom Command Definition (
atmos.yaml):- The
examplecommand defines a custom component type - Arguments and flags with
provides: componentandprovides: stackidentify which values to use - The
component:section specifies the component type name
- The
-
Stack Configuration (
stacks/):- Components are defined under
components.example.<name> - Standard Atmos inheritance and overrides work as expected
- Components are defined under
-
Template Access:
- Steps can access component config via
{{ .Component.* }} - All component sections are available:
vars,settings,metadata, etc.
- Steps can access component config via
-
Environment Variables:
- The component
envsection is exported as real environment variables to every step, just like the built-interraform/helmfile/packer/ansiblecomponent types. - Steps (and scripts they invoke) read them directly as
$APP_VERSION,$DEPLOY_REGION, etc. - For sensitive values, use
!secret NAMEin theenvsection so the value resolves from a secret backend and is masked in output — never inline a secret into the command string. See Passing secrets.
- The component