Skip to main content
EXAMPLE

Native Terraform Migration

This example demonstrates migrating from [native Terraform](https://atmos.tools/cli/commands/terraform/usage) (with [`.tfvars` files](https://atmos.tools/stacks/vars)) to Atmos.

Terraform
cloudposse / atmos

Try it out

Copy the example into a new directory and make it your own:

atmos init examples/native-terraform
cd native-terraform

Follow the README for prerequisites and next steps.

See it in action

RECORDED DEMO
native-terraform
 
Recorded from this example
Real commands. Real output.
README.md2.5 KB
View on GitHub

Native Terraform Migration Example

This example demonstrates migrating from native Terraform (with .tfvars files) to Atmos.

Overview

The example shows two migration strategies side by side:

StackFileStrategyStack Name
devstacks/dev.yamlKeep existing .tfvars via !includedev (from filename)
prodstacks/prod.yamlConvert to native YAMLproduction (explicit name)

Directory Structure

├── atmos.yaml # Atmos configuration
├── components/terraform/vpc/ # Your Terraform root module
│ ├── main.tf
│ ├── variables.tf
│ ├── outputs.tf
│ └── envs/ # Existing .tfvars files
│ ├── dev.tfvars
│ └── prod.tfvars
└── stacks/
├── _defaults.yaml # Shared defaults (imported by both stacks)
├── dev.yaml # Uses !include for existing tfvars
└── prod.yaml # Fully converted to YAML

Key Concepts

!include for .tfvars

The dev stack uses !include to import existing .tfvars files directly:

components:
terraform:
vpc:
vars: !include ../components/terraform/vpc/envs/dev.tfvars

This is the fastest migration path — your existing variable files keep working.

Stack Names

The prod stack uses an explicit name field to override the filename:

name: production

This means you reference it as atmos terraform plan vpc -s production, not -s prod.

Imports

Both stacks import shared defaults from _defaults.yaml:

import:
- _defaults

Usage

# List all stacks
atmos list stacks

# Dev stack (uses !include for tfvars)
atmos terraform plan vpc -s dev
atmos describe component vpc -s dev

# Prod stack (explicit name, converted to YAML)
atmos terraform plan vpc -s production
atmos describe component vpc -s production

# This will NOT work (filename is not the canonical name):
# atmos terraform plan vpc -s prod