atmos terraform
Use these subcommands to interact with Terraform and OpenTofu.
Atmos supports all Terraform and OpenTofu commands and options described in Terraform CLI Overview and OpenTofu Basic CLI Features.
The term "Terraform" is used in this documentation to refer to generic concepts such as providers, modules, stacks, the HCL-based domain-specific language and its interpreter. Atmos works with OpenTofu.
Command Modes
Atmos Terraform commands operate in two modes:
- Single-Component: Execute Terraform for one component at a time with precise control
- Multi-Component: Execute Terraform across multiple components using filters (
--all,--affected,--components,--query)
Single-Component Usage
Use single-component commands when you want to execute Terraform operations on one component at a time.
The component argument and --stack flag are required to generate variables and backend config for the component in the stack.
See individual command pages for detailed options: plan, apply, deploy, destroy.
Path-Based Component Resolution
Atmos supports using filesystem paths instead of component names for convenience. This allows you to navigate to a component directory and use . to reference it:
This automatically resolves the path to the component name configured in your stack, eliminating the need to remember exact component names.
Supported path formats:
.- Current directory./component- Relative path from current directory../other-component- Relative path to sibling directory/absolute/path/to/component- Absolute path
Requirements:
- Must be inside a component directory under the configured base path
- Must specify
--stackflag - Component must exist in the specified stack configuration
When a component path matches multiple components in the stack, Atmos prompts you to select which one to use in interactive terminals.
For example, if both station/1 and station/2 reference components/terraform/weather:
cd components/terraform/weather
atmos terraform plan . --stack dev
# Atmos displays: "Component path '.' matches multiple instances in stack 'dev'"
# Select which component instance to use: station/1, station/2
In non-interactive mode (CI/CD), use the explicit component name to avoid ambiguity:
atmos terraform plan station/1 --stack dev # Explicit and unambiguous
atmos terraform plan station/2 --stack dev # Explicit and unambiguous
Multi-Component Usage
Use multi-component commands to run Terraform operations across multiple components simultaneously. You can target components by stack, selector, query, or change detection.
All multi-component flags can be combined with --dry-run to preview what would be executed without making changes.
See individual command pages for detailed multi-component examples and flags: plan, apply, deploy.
Differences from Native Terraform
Atmos enhances the standard Terraform CLI with several conveniences:
-
Automatic initialization: Atmos runs
terraform initbefore executing other commands. Use--skip-initto skip this step. -
Deploy command:
atmos terraform deployexecutesterraform apply -auto-approvefor automated deployments. -
Planfile support: The
--from-planand--planfileflags enable two-stage plan/apply workflows. See Terraform Planfiles. -
Terraform Cloud compatibility: Use
--skip-planfilewithterraform planwhen using Terraform Cloud, which doesn't support local plan files. -
Native flag passthrough: Use
--to pass flags directly to Terraform:atmos terraform plan vpc -s dev -- -refresh=false
atmos terraform apply vpc -s dev -- -lock=false
Run atmos terraform --help to see all available options.
Configure Terraform
Learn how to configure Terraform components in your atmos.yaml, including backends, workspaces, and provider generation.
Subcommands
🗃️ generate
6 items
🗃️ source
4 items
📄️ apply
Use this command to apply Terraform changes for an Atmos component in a stack. Supports both direct applies and applying from previously generated planfiles.
📄️ backend
Manage Terraform state backend infrastructure
📄️ clean
Use this command to clean up Terraform files for an Atmos component in a stack. This removes .terraform folder, .terraform.lock.hcl file, and Atmos-generated varfiles and planfiles.
📄️ console
Use this command to open an interactive Terraform console for an Atmos component in a stack, with all component variables and configuration pre-loaded.
📄️ deploy
Use this command to deploy Terraform changes for an Atmos component in a stack with auto-approval. This combines plan and apply operations in a single command.
📄️ destroy
Use this command to destroy Terraform-managed infrastructure for an Atmos component in a stack. This operation removes all resources managed by the component.
📄️ fmt
Use this command to format Terraform HCL configuration files for an Atmos component to canonical format and style.
📄️ force-unlock
Use this command to manually unlock the Terraform state for an Atmos component in a stack when automatic unlocking fails.
📄️ get
Use this command to download and update Terraform modules for an Atmos component. This ensures all module dependencies are available locally.
📄️ graph
Use this command to generate a visual dependency graph for an Atmos component's Terraform resources in a specific stack.
📄️ import
Use this command to import existing infrastructure resources into the Terraform state for an Atmos component in a stack.
📄️ init
Use this command to initialize the Terraform working directory for an Atmos component in a stack. This prepares the component for other Terraform operations.
📄️ login
Use this command to authenticate with Terraform Cloud or Terraform Enterprise for an Atmos component in a stack.
📄️ logout
Use this command to remove Terraform Cloud or Terraform Enterprise credentials for an Atmos component in a stack.
📄️ metadata
Use this command to retrieve Terraform metadata functions for an Atmos component in a stack.
📄️ modules
Use this command to list all Terraform modules used by an Atmos component in a stack.
📄️ output
Use this command to read Terraform output values for an Atmos component in a stack from the state file.
📄️ plan-diff
The atmos terraform plan-diff command compares two Terraform plans and shows the differences between them.
📄️ plan
Use this command to generate a Terraform execution plan for an Atmos component in a stack, showing what changes would be made to your infrastructure.
📄️ providers
Use this command to display provider requirements and configurations for an Atmos component's Terraform configuration in a stack.
📄️ refresh
Use this command to refresh the Terraform state for an Atmos component in a stack, updating it to match the current remote infrastructure.
📄️ shell
This command starts a new `SHELL` configured with the environment for an Atmos component in a stack to allow execution of all native terraform commands inside the shell without using any atmos-specific arguments and flags. This may by helpful to debug a component without going through Atmos.
📄️ show
Use this command to display human-readable output from the Terraform state or planfile for an Atmos component in a stack.
📄️ state
Use this command to manage the Terraform state for an Atmos component in a stack. Supports operations like list, move, pull, push, replace-provider, rm, and show.
📄️ taint
Use this command to mark a Terraform resource for recreation in an Atmos component's next apply operation. Note: This command is deprecated in Terraform v1.0+.
📄️ test
Use this command to run Terraform tests for an Atmos component, validating the component's configuration and behavior.
📄️ untaint
Use this command to remove the tainted state from a Terraform resource in an Atmos component. Note: This command is deprecated in Terraform v1.0+.
📄️ validate
Use this command to validate the Terraform HCL configuration files (.tf files) for an Atmos component in a stack, checking for syntax and consistency errors. This validates Terraform code, not Atmos stack YAML configurations.
📄️ version
Use this command to display the Terraform/OpenTofu version being used for an Atmos component in a stack.
📄️ workspace
This command calculates the `terraform` workspace for an Atmos component (from the context variables and stack config). It runs `terraform init -reconfigure` and selects the workspace by executing the `terraform workspace select` command.
🗃️ workdir
4 items