Your First Stack
Let's create the simplest possible Atmos stack—no imports, no inheritance, no complexity. Just a component plus configuration that works.
Think of this like "Hello World" for Atmos. We'll take one Terraform component and configure it with one stack file. That's it.
Prerequisites
- Atmos installed
- Basic Terraform knowledge
- A Terraform component (or create a simple one)
Step 1: Create a Simple Component
First, create a basic Terraform component. We'll use a simple example that creates an S3 bucket:
components/terraform/s3-bucket/main.tf
components/terraform/s3-bucket/versions.tf
This is just an example. You can use any existing Terraform root module you have—Atmos works with vanilla Terraform.
Step 2: Create an Atmos Configuration
Create atmos.yaml in your repository root:
atmos.yaml
This tells Atmos:
- Where to find Terraform components (
components/terraform/) - Where to find stack configurations (
stacks/) - How to name stacks (using the
stagevariable)
Step 3: Create Your First Stack
Now create a stack configuration for development:
stacks/dev.yaml
Let's break this down:
vars(top level): Variables available to all components in this stackcomponents.terraform.my-bucket: This is a component instance—a configured instance of thes3-bucketcomponentmetadata.component: Points to the actual Terraform component incomponents/terraform/s3-bucketvars(component level): Variables specific to this component instance
Step 4: Deploy Your Stack
If the plan looks good:
atmos terraform apply my-bucket -s dev
What Just Happened?
Atmos did several things automatically:
- Found the component: Located
components/terraform/s3-bucketbased onmetadata.component - Merged variables: Combined global
varswith component-specificvars - Generated tfvars: Created a
.tfvarsfile with:bucket_name = "my-dev-bucket-12345"
environment = "development"
stage = "dev"
region = "us-east-1" - Ran Terraform: Executed
terraform applyin the component directory
Add Another Environment
Creating a production stack is just another YAML file:
stacks/prod.yaml
Deploy it:
atmos terraform apply my-bucket -s prod
Same component, different configuration—that's the power of separation.
Key Takeaways
- Stacks are YAML configurations for components
- Components are generic Terraform code
- Variables merge from global to component level
- Component instances let you use the same component with different names
What's Next
This example is intentionally simple. In real projects, you'll want to:
- Understand YAML deeply: Learn about deep merge, scope, and YAML functions
- Reuse configuration: Use imports to stay DRY
- Create variations: Use inheritance for component variants
- Organize at scale: Use catalogs and patterns
But you've now deployed your first stack—everything else builds on this foundation.