Deploy Everything
After you've written your components and configured your stacks, now we're ready to deploy them!
You will learn
- How Atmos identifies components using context variables and naming patterns
- How to preview your configurations and changes before applying them
- How to deploy every Terraform component in a selected stack
Deploy the Stack
Before deploying, validate the stack manifests:
atmos validate stacks
You can also orient yourself with the built-in list commands:
atmos list stacks
atmos list instances -s dev
Preview every Terraform component in the dev stack:
atmos terraform plan --all -s dev
Deploy every Terraform component in the dev stack:
atmos terraform deploy --all -s dev
When you're done, you can destroy every Terraform component in the stack:
atmos terraform destroy --all -s dev -auto-approve
For single-component Terraform commands, you can name the component explicitly or omit the component and stack in an interactive terminal so Atmos can prompt you:
# Explicit
atmos terraform plan station -s dev
# Interactive: choose component, then stack
atmos terraform plan
For bulk operations, use explicit selectors such as --all, --components, or --query.
Stack Search Algorithm
Looking at the commands above, you might have a question "How does Atmos find the component in the stack and all the variables?"
Let's consider what Atmos does when executing the command atmos terraform deploy --all -s dev:
-
Atmos uses the
stacks.name_templatedefined in the CLI config. In this example, we have defined a simple name based onstacks.name_template: "{{ .vars.stage }}". This means that the stack name is just thestagepart of the stack name. -
Atmos searches for the stack configuration file (in the
stacksfolder and all sub-folders) wherestage: devis defined (inline or via imports). During the search, Atmos processes all parent (top-level) config files and compares the context variables specified in the command (-sflag) with the context variables defined in the stack configurations, finally finding the matching stack -
Atmos finds every Terraform component in the stack. In this simple Quick Start, that means Atmos resolves the
stationcomponent by processing all the inline configs and all the imports -
Atmos deep-merges all the catalog imports for the
stationcomponent and then deep-merges all the variables for the component defined in all sections (globalvars, terraformvars, base componentsvars, componentvars), producing the final variables for thestationcomponent in thedevstack -
And lastly, Atmos writes the final deep-merged variables into a
.tfvar.jsonfile in the component directory and then executes the Terraform command
Now that you’ve seen Atmos in action, you can explore the extra credit!
Or take a moment to explore its core concepts. You have only just scratched the surface of Atmos. Atmos is a powerful enterprise-grade framework with so much more to offer!