atmos terraform 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.
Usage
Execute the terraform apply command like this:
atmos terraform apply <component> -s <stack> [options]
This command applies Terraform changes to your infrastructure. You can:
- Apply changes directly (generates a new plan and prompts for approval)
- Apply a previously generated planfile using
--from-plan - Apply a specific planfile using
--planfile <path> - Auto-approve changes using
-auto-approve
When saved plan policies are enabled with ATMOS_POLICY_DIR,
apply requires --from-plan or --planfile. Atmos reevaluates the selected artifact and applies a
private copy of those same bytes. Implicit plan-and-apply is rejected while this gate is configured.
For automated deployments, consider using atmos terraform deploy which automatically includes -auto-approve.
apply does not download stored planfiles or run
drift verification. It applies a planfile passed
with --planfile, or—when none is given—lets Terraform plan and apply in one step; in neither case does
Atmos capture a separate fresh plan to diff a stored plan against. The automatic download → verify →
apply flow lives on
atmos terraform deploy, which runs
a discrete plan step as part of the command.
Examples
Interactive Apply
Apply changes interactively (you'll be prompted to approve):
atmos terraform apply vpc -s dev
Apply from Previous Plan
Apply using the planfile generated by a previous atmos terraform plan:
# First generate a plan
atmos terraform plan vpc -s dev
# Then apply using that plan
atmos terraform apply vpc -s dev --from-plan
Apply Specific Planfile
Apply a specific planfile:
# Using a custom planfile created earlier
atmos terraform apply vpc -s dev --planfile /tmp/my-plan.tfplan
# Or relative to component directory
atmos terraform apply vpc -s dev --planfile plans/vpc.tfplan
Auto-Approved Apply
Apply changes without manual approval (use with caution):
atmos terraform apply vpc -s dev -auto-approve
Targeted Apply
Apply changes only to specific resources:
atmos terraform apply vpc -s dev -target=aws_subnet.private
Graph-backed Bulk Apply
Run applies for multiple components through the Terraform dependency graph:
# Apply every Terraform component in dependency order
atmos terraform apply --all -s dev
# Apply a named subset, preserving dependency edges between selected components
atmos terraform apply --components vpc,eks/cluster,eks/apps -s dev
# Apply components selected by query
atmos terraform apply --query '.settings.tier == "network"' -s dev
# Apply only affected components that are also tagged "production"
atmos terraform apply --affected --tags production -s dev
The graph is built from dependencies.components first, with settings.depends_on as a fallback. Atmos applies prerequisites before dependents so components that consume another component's outputs run after the component they depend on.
Use --failure-mode keep-going to continue independent graph branches after one component fails. The default is fail-fast.
Planfile Usage
Using Atmos-Generated Planfiles
When you run atmos terraform plan, Atmos automatically generates a planfile with a standardized name. You can apply this planfile using the --from-plan flag:
# Generate the plan
atmos terraform plan vpc -s dev
# Review the plan output...
# Apply the exact plan that was generated
atmos terraform apply vpc -s dev --from-plan
This ensures that only the changes you reviewed will be applied, with no risk of configuration drift between planning and applying.
Using Custom Planfiles
If you generated a plan with a custom output path, use the --planfile flag:
# Generate plan to custom location
atmos terraform plan vpc -s dev -out=/tmp/vpc-dev.tfplan
# Apply that specific planfile
atmos terraform apply vpc -s dev --planfile /tmp/vpc-dev.tfplan
Direct Apply (No Planfile)
When neither --from-plan nor --planfile is specified, Atmos will:
- Generate a new plan
- Show the planned changes
- Prompt for approval (unless
-auto-approveis used) - Apply the changes if approved
atmos terraform apply vpc -s dev
Arguments
component(required)Atmos component name to apply.
Flags
--stack/-s(required)Atmos stack name where the component is defined.
--from-plan(optional)Apply the planfile previously generated by
atmos terraform plan.The planfile must exist in the component directory with the standard Atmos naming convention.
atmos terraform apply vpc -s dev --from-plan--planfile(optional)Apply a specific planfile at the given path.
Use this instead of the native Terraform planfile argument.
atmos terraform apply vpc -s dev --planfile /path/to/plan.tfplan--affected(optional)Apply only affected components based on changes in the repository.
atmos terraform apply --affected--all(optional)Apply all components in all stacks (use with extreme caution).
atmos terraform apply --all--dry-run(optional)Show what would be executed without actually running the apply.
atmos terraform apply vpc -s dev --dry-run--skip-init(optional)Skip running
terraform initbefore applying.atmos terraform apply vpc -s dev --skip-init--init-mode(optional)Override
init.modefor this invocation:auto(default, skip init when nothing relevant changed),always, ornever(disables the ordinary implicit init, but unlike--skip-initdoes not suppress the forced reconfigure init thatatmos terraform workspace select/newneeds).atmos terraform apply vpc -s dev --init-mode=always--init-reconfigure(optional)Override
init.reconfigurefor this invocation:auto(default),always, ornever.atmos terraform apply vpc -s dev --init-reconfigure=always--init-upgrade(optional)Override
init.upgradefor this invocation:auto(default),always, ornever.atmos terraform apply vpc -s dev --init-upgrade=always--process-templates(optional)Enable/disable Go template processing in Atmos stack manifests.
Default:
trueatmos terraform apply vpc -s dev --process-templates=false--ui(optional)Enable streaming UI mode for real-time resource status display. Shows a Docker-build-style progress view with spinners, progress bar, and resource states.
The UI automatically disables when output is piped, in CI environments, or when running unsupported commands.
--uierrors when combined with--max-concurrencygreater than1, since concurrently-scheduled components can't share one terminal for their full-screen UI sessions. Use--max-concurrency 1(the default) with--ui, or drop--uito run concurrently.atmos terraform apply vpc -s dev --uiUse
--ui=falseto explicitly disable when enabled by config.--max-concurrency(optional)Maximum number of components to apply concurrently when running with
--all,--affected,--components, or--query. Default is1(sequential).Environment variable:
ATMOS_TERRAFORM_APPLY_MAX_CONCURRENCYatmos terraform apply --all -s dev --max-concurrency 4--failure-mode(optional)Controls how the concurrent scheduler handles a failed component when using
--all,--affected,--components, or--querywith--max-concurrency > 1.Supported values:
fail-fast(default) — stop scheduling new components as soon as one failskeep-going— continue applying independent graph branches even after a failure
Environment variable:
ATMOS_TERRAFORM_APPLY_FAILURE_MODEatmos terraform apply --all -s dev --max-concurrency 4 --failure-mode keep-going--log-order(optional)Controls how concurrent per-component logs are ordered when
--max-concurrencyis greater than1.Supported values:
stream(default) — print log lines as they arrive, interleaved across componentsgrouped— buffer each component's output and print it as a contiguous block after the component finishes, prefixing every stdout and stderr line with[stack/component]. Saved per-component log files remain unprefixed.
Environment variable:
ATMOS_TERRAFORM_APPLY_LOG_ORDERatmos terraform apply --all -s dev --max-concurrency 4 --log-order grouped--ci(optional)Enable CI mode for automated pipelines. When enabled, Atmos writes job summaries, CI output variables, and status checks based on the
ciconfiguration inatmos.yaml.CI mode is auto-detected when
CI=trueorGITHUB_ACTIONS=trueenvironment variables are set.Environment variables:
ATMOS_CI,CIatmos terraform apply vpc -s dev --ci
Native Terraform Flags
The atmos terraform apply command supports all native terraform apply flags. To pass native Terraform flags, you have two options:
- Direct flags - Pass Terraform flags directly if they don't conflict with Atmos flags
- Double-dash separator - Use
--to explicitly separate Atmos flags from Terraform flags
The -- separator is a common Unix convention that indicates "end of options". Everything after -- is passed directly to Terraform without interpretation by Atmos. This is useful when:
- You want to ensure a flag is passed to Terraform, not Atmos
- You're using flags that might conflict with Atmos flags
- You want to be explicit about which tool receives which flags
Example:
atmos terraform apply vpc -s dev -- -auto-approve -parallelism=20
Some commonly used native flags include:
-auto-approveApply changes without manual approval prompt.
atmos terraform apply vpc -s dev -auto-approvewarningUse
-auto-approvewith caution, especially in production environments.-target=RESOURCEApply changes only to specific resources. Can be specified multiple times.
atmos terraform apply vpc -s dev -target=aws_subnet.private -target=aws_route_table.private-var 'NAME=VALUE'Set a variable value. Can be specified multiple times.
atmos terraform apply vpc -s dev -var="instance_count=3"-refresh-onlyOnly update the state to match remote systems.
atmos terraform apply vpc -s dev -refresh-only-replace=RESOURCEForce replacement of a specific resource.
atmos terraform apply vpc -s dev -replace=aws_instance.web
Default Locking and Concurrency Flags
Instead of retyping flags like -lock-timeout on every invocation, declare a default
in components.terraform.flags — globally
in atmos.yaml, per stack, or per component. When applying a freshly computed plan (not a
saved planfile), apply supports all five flags (lock_timeout, lock, parallelism,
refresh, compact_warnings); when applying a saved planfile, Terraform rejects
-refresh, so it is not injected in that case. A native flag typed directly on the
command line (as shown above) always wins over a declared default.
Best Practices
Two-Stage Apply Process
For production environments, we recommend a two-stage apply process:
# Stage 1: Generate and review the plan
atmos terraform plan vpc -s prod
# Review the plan output carefully...
# Stage 2: Apply the exact reviewed plan
atmos terraform apply vpc -s prod --from-plan
This ensures that:
- Changes are reviewed before applying
- No configuration drift occurs between plan and apply
- The exact reviewed changes are applied
Automated Deployments
For CI/CD pipelines, you can:
-
Generate a plan in one job:
atmos terraform plan vpc -s prod -out=plan.tfplan -
Apply the plan in another job (after approval):
atmos terraform apply vpc -s prod --planfile plan.tfplan
Or use atmos terraform deploy for fully automated deployments:
atmos terraform deploy vpc -s prod
Interrupting an Apply
Press Ctrl-C once to stop an apply safely. Atmos waits for Terraform to finish or taint the resource it is working on, save state, and release the state lock before it exits. Press Ctrl-C again only if you must stop immediately; like a second Ctrl-C on plain Terraform, that can lose state. See Interrupting Terraform.
Multi-Component Operations
Execute terraform apply across multiple components using filtering flags. All flags can be combined with --dry-run to preview what would be executed.
Multi-component apply operations can make significant infrastructure changes. Always use --dry-run first to verify which components will be affected.
Apply All Components
# Apply all components in all stacks
atmos terraform apply --all
# Apply all components in a specific stack
atmos terraform apply --all --stack prod
atmos terraform apply --stack prod
Apply Affected Components
Apply only components affected by changes in the current branch (requires git). Components are processed in dependency order:
# Apply affected components in all stacks
atmos terraform apply --affected
# Apply affected components in a specific stack
atmos terraform apply --affected --stack prod
# Include dependent components (components that depend on affected components)
atmos terraform apply --affected --include-dependents
# Clone the target reference instead of checking it out
atmos terraform apply --affected --clone-target-ref=true
Apply Specific Components
# Apply specific components in all stacks
atmos terraform apply --components vpc,eks
# Apply specific components in a specific stack
atmos terraform apply --components vpc,eks --stack prod
Apply Components by Query
Filter components using YQ expressions against component configuration:
# Apply components where team tag equals "eks"
atmos terraform apply --query '.vars.tags.team == "eks"'
# Apply components in a specific account
atmos terraform apply --query '.settings.context.account_id == 12345'
# Combine with stack filter
atmos terraform apply --query '.vars.tags.team == "eks"' --stack prod
Apply Components by Tags and Labels
Filter components by metadata.tags/metadata.labels. These flags compose with --all/--affected/--components/--query to narrow the selected set further, rather than being mutually exclusive with them:
# Apply components tagged production or tier-1 (matches any)
atmos terraform apply --tags production,tier-1
# Apply components labeled cost-center=platform (matches all given labels)
atmos terraform apply --labels cost-center=platform
# Combine multiple selectors in one comma-separated --labels value
atmos terraform apply --labels cost-center=platform,compliance=sox
# Narrow an --affected run to only production-tagged components
atmos terraform apply --affected --tags production
Include Dependencies and Dependents
--include-dependencies adds prerequisites even when they do not match the selectors or belong to another stack.
--include-dependents honors --tags and --labels, retaining matching descendants of excluded components in dependency
order. See Terraform selection flags for full semantics.
For example, --include-dependencies with -s dev can include prerequisites outside dev:
# Apply dev-labeled components plus everything they depend on
atmos terraform apply --labels=env=dev --include-dependencies
# Bound the expansion to direct dependencies only
atmos terraform apply --labels=env=dev --include-dependencies=1
# Apply a stack plus everything that depends on it, up to two levels out
atmos terraform apply -s dev --include-dependents=2
Pass the depth with = (for example, --include-dependencies=2); a space-separated value is not bound to the flag. The bare flag expands without a depth limit, and true/false values are accepted for backward compatibility.
Multi-Component Flags
--all- Apply all components in all stacks (or specified stack with
--stack). --affected- Apply components affected by git changes in dependency order. Supports all flags from
atmos describe affected. --components- Apply specific components by name (comma-separated or repeated flag).
--query- Apply components matching a YQ expression. All Atmos sections are available:
vars,settings,env,metadata, etc. --tags- Filter by tags (comma-separated, matches any):
--tags=production,tier-1. Composes with--all/--affected/--components/--queryto narrow the selected set further; cannot be combined with a single component argument. --labels- Filter by labels (comma-separated
key=valueorkey:valuepairs in one flag value, matches all):--labels=cost-center=platform,compliance=sox. Composes with--all/--affected/--components/--query/--tags; cannot be combined with a single component argument. --include-dependencies- Also apply everything the selected components depend on (their prerequisites), in dependency order — even when the prerequisites live in other stacks or do not match the selectors. Accepts an optional depth: the bare flag expands the full dependency chain, while
--include-dependencies=1bounds it to direct dependencies. Requires a multi-component selection.
Environment variable:ATMOS_INCLUDE_DEPENDENCIES --include-dependents- Also apply everything that depends on the selected components, in dependency order. Works with any multi-component selection (
--all,--components,--query,--stack,--tags,--labels,--affected). Accepts an optional depth: the bare flag expands the full dependent chain, while--include-dependents=2bounds it to two levels.
Environment variable:ATMOS_INCLUDE_DEPENDENTS --ref- Git reference to compare against (branch or tag). Default:
refs/remotes/origin/HEAD. --sha- Git commit SHA to compare against.
--clone-target-ref- Clone the target reference instead of checking it out locally.
CI Integration
ExperimentalWhen running in CI mode (--ci flag or auto-detected), Atmos produces rich CI artifacts:
- Job summaries with resource counts, apply results, and terraform outputs written to
$GITHUB_STEP_SUMMARY - Output variables (
success,has_changes,exit_code, etc.) written to$GITHUB_OUTPUT - Status checks showing apply progress and results (requires
ci.checks.enabled: true)
# In GitHub Actions (auto-detected)
atmos terraform apply vpc -s dev
# Explicit CI mode
atmos terraform apply vpc -s dev --ci
See CI Configuration for full configuration options including custom templates, status checks, and output variables.
Try it out
- Install Atmos
- Try the example
Copy the example into a new directory and make it your own:
atmos init examples/quick-start-simple
cd quick-start-simple
Requires Terraform and network access for provider downloads and the public weather API. The example writes a local weather cache file; no cloud credentials are needed. Apply and destroy prompt for confirmation.
atmos terraform init station -s dev
atmos terraform apply station -s dev
atmos terraform destroy station -s dev
Related Commands
atmos terraform plan- Generate an execution planatmos terraform deploy- Apply with auto-approvalatmos terraform destroy- Destroy infrastructureatmos terraform plan-diff- Compare plan files
Configuration
Configure default behavior for terraform apply in your atmos.yaml:
components:
terraform:
# Auto-approve all applies (use with caution)
apply_auto_approve: false
# Auto-generate backend configuration
auto_generate_backend_file: true
See Terraform Planfiles for a comprehensive guide on working with planfiles in Atmos.
The atmos terraform apply command supports all native terraform apply options described in Terraform apply options, except that planfile arguments should use --from-plan or --planfile flags instead of being passed directly.