Terraform/OpenTofu
Atmos manages Terraform root modules as components, handling workspace selection, backend configuration, provider overrides, and variable generation.
Overview
In Atmos, a Terraform component is a Terraform root module stored in your components/terraform/ directory. Atmos orchestrates these components by:
- Generating variables from stack configurations into
.tfvarsfiles - Managing workspaces automatically based on stack context
- Configuring backends for state storage
- Generating providers with dynamic configurations
- Orchestrating execution across multiple components and stacks
-
Terraform Component is a Terraform Root Module stored typically in
components/terraform/$namethat consists of the resources defined in the.tffiles in a working directory (e.g. components/terraform/infra/vpc) -
Stack provides configuration (variables and other settings) for a Terraform Component and is defined in one or more Atmos stack manifests (a.k.a. stack config files)
Provisioning Components
To provision a Terraform component using the atmos CLI:
atmos terraform plan eks --stack=ue2-dev
atmos terraform apply eks --stack=ue2-dev
where:
eksis the Terraform component to provision (from thecomponents/terraformfolder)--stack=ue2-devis the stack to provision the component into
Short versions of all command-line arguments can be used:
atmos terraform plan eks -s ue2-dev
atmos terraform apply eks -s ue2-dev
The atmos terraform deploy command executes terraform apply -auto-approve to provision components in stacks without
user interaction:
atmos terraform deploy eks -s ue2-dev
Stack Configuration
Configure Terraform components in your stack manifests:
components:
terraform:
vpc:
metadata:
type: real
component: vpc
inherits:
- vpc-defaults
vars:
enabled: true
name: primary
cidr_block: "10.0.0.0/16"
env:
TF_LOG: INFO
settings:
spacelift:
workspace_enabled: true
See Stack Configuration for the complete schema reference.
Using Submodules (Child Modules)
If your components rely on local submodules, our convention is to use a modules/ subfolder of the component to store them.
Related Topics
Complete reference for configuring Terraform components in Atmos stacks
Learn why Atmos can change how you think about the Terraform modules that you use to build your infrastructure.
Configure Terraform/OpenTofu state backends.
Configure Terraform workspaces.
Configure and generate Terraform providers.
Atmos provides sophisticated planfile management for Terraform, enabling safe and predictable infrastructure changes through plan generation, storage, and application workflows.
There are some considerations you should be aware of when adopting Atmos in a brownfield environment. Atmos works best when you adopt the Atmos mindset.