Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
604790f
docs: add comprehensive Terraform planfile documentation
osterman Sep 23, 2025
bc3f922
docs: add complete reference documentation for all Terraform commands
osterman Sep 23, 2025
e817762
fix: correct broken links in Terraform documentation
osterman Sep 23, 2025
0df409d
chore: add all Terraform command help screengrabs to demo-stacks.txt
osterman Sep 23, 2025
3890f07
docs: add Atmos behavior information to all Terraform command documen…
osterman Sep 23, 2025
709ca77
docs: enhance Terraform planfile documentation with backend limitatio…
osterman Sep 23, 2025
b5f934d
chore: remove temporary Python script used for documentation updates
osterman Sep 23, 2025
93525ec
chore: add terraform screengrab generation helper files
osterman Sep 23, 2025
7be6e51
docs: fix documentation issues and broken links in Terraform command …
osterman Sep 23, 2025
ec32d83
docs: fix terraform untaint usage synopsis to include resource_address
osterman Sep 23, 2025
8b79c94
chore: remove temporary Python script used for documentation updates
osterman Sep 23, 2025
b020e7c
docs: replace purpose notes with Intro blocks and make descriptions A…
osterman Sep 23, 2025
5978f89
chore: add terraform screengrab generation helper files
osterman Sep 23, 2025
c3c5f41
docs: fix Terraform backend limitations and restore documentation acc…
osterman Sep 24, 2025
b5eb179
chore: generate remaining screengrabs for packer and list commands
osterman Sep 24, 2025
9696606
docs: add security warning about credential embedding in planfiles
osterman Sep 24, 2025
497d524
docs: fix documentation inconsistencies and remove unvalidated examples
osterman Sep 24, 2025
6eef644
chore: remove temporary cleanup script
osterman Sep 24, 2025
59bbcd8
Merge branch 'main' into custom-planfile - resolve conflicts
osterman Sep 24, 2025
9dc3d5a
Merge remote-tracking branch 'origin/main' into custom-planfile
osterman Oct 3, 2025
d12f7a7
chore: remove obsolete Terraform help generation scripts
osterman Oct 3, 2025
31eadc6
chore: remove Terraform flag support analysis document
osterman Oct 3, 2025
de1fbd1
fix: remove stray closing Terminal tag causing MDX build failure
osterman Oct 3, 2025
6117e8a
docs: address review comments on terraform validate and planfile docu…
osterman Oct 3, 2025
71852c3
Merge remote-tracking branch 'origin/main' into custom-planfile
osterman Oct 6, 2025
ddf395d
fix: resolve broken documentation links
osterman Oct 6, 2025
3a3403a
fix: resolve website build failures with missing imports and broken l…
osterman Oct 6, 2025
d43d99b
docs: add instructions for regenerating screengrabs
osterman Oct 6, 2025
a14d5b3
docs: update Docker command to avoid pipe indirection
osterman Oct 6, 2025
a17be40
docs: add warning against using pipe indirection for screengrabs
osterman Oct 6, 2025
3a134a2
fix: add missing resource_address in terraform untaint examples
osterman Oct 7, 2025
33127d8
docs: clarify terraform fmt formats HCL configuration files
osterman Oct 7, 2025
583d69d
Merge branch 'main' into custom-planfile
osterman Oct 7, 2025
1b28561
chore: update screengrabs and switch to podman for docker-build target
osterman Oct 7, 2025
8eb52fb
chore: improve screengrab generation documentation and disable pager
osterman Oct 7, 2025
b659f11
chore: remove temporary screengrab files with invalid names
osterman Oct 7, 2025
b490497
feat: add safeguards to screengrab generation and use released atmos …
osterman Oct 7, 2025
0db088b
fix: correct shell variable escaping in docker-build Makefile target
osterman Oct 7, 2025
eae52a8
chore: disable telemetry in screengrab generation
osterman Oct 7, 2025
110366c
fix: prevent script command from hanging in Linux containers
osterman Oct 7, 2025
ae8d69e
fix: add TTY allocation to podman for script command compatibility
osterman Oct 7, 2025
69e4617
fix: filter terminal escape sequences from screengrabs
osterman Oct 7, 2025
cdcc694
fix: replace script command with direct output capture on Linux
osterman Oct 7, 2025
637dfe3
fix: correct script command usage for Linux screengrabs
osterman Oct 7, 2025
26e1e02
fix: use script -f flag and close stdin to prevent hanging
osterman Oct 7, 2025
3e393d8
feat: use ATMOS_COLOR=true to force colored output without TTY
osterman Oct 7, 2025
3f6fe33
fix(screengrabs): improve docker-build with validation and latest atm…
osterman Oct 7, 2025
95f15a9
feat: use ATMOS_FORCE_COLOR to force colored output without TTY
osterman Oct 12, 2025
b9c73ea
fix: simplify early-return pattern in root.go
osterman Oct 12, 2025
ca4adc5
docs: fix markdown headings and portable sed usage
osterman Oct 12, 2025
256529f
fix(screengrabs): add validation to prevent script command artifacts
osterman Oct 12, 2025
41720c9
fix(screengrabs): upgrade to Go 1.23 for container builds
osterman Oct 12, 2025
75bfc7d
chore: regenerate screengrabs with ATMOS_FORCE_COLOR
osterman Oct 12, 2025
9ff09ee
fix: enable Cobra help text colors with ATMOS_FORCE_COLOR
osterman Oct 12, 2025
ca53a1b
fix: improve FORCE_COLOR support with truthiness checking and ANSI256…
osterman Oct 14, 2025
57aec26
chore: regenerate screengrabs with updated help system
osterman Oct 14, 2025
1bc39f2
Merge branch 'main' into custom-planfile
osterman Oct 14, 2025
5f9166b
refactor: add performance tracking and refactor help template
osterman Oct 14, 2025
eb7d4f1
refactor: reduce cognitive complexity in UI rendering functions
osterman Oct 14, 2025
d5deb45
refactor: expand FORCE_COLOR parsing and rename color constants
osterman Oct 14, 2025
daa0b7d
fix: correct documentation and add performance tracking
osterman Oct 14, 2025
21869d2
fix: correct helmfile sync description in Go source
osterman Oct 14, 2025
d59d557
docs: add blog post introducing enhanced CLI experience and documenta…
osterman Oct 16, 2025
0793e59
Merge branch 'main' into custom-planfile
osterman Oct 21, 2025
25a38c1
Merge branch 'main' into custom-planfile
Nov 14, 2025
aed62b1
Remove .ansi files and add to .gitignore
Nov 14, 2025
73b7697
Add dependency checks to screengrabs build script
Nov 14, 2025
572c187
Add Brewfile for screengrabs dependencies
Nov 14, 2025
392f827
Fix sed in-place editing to prevent '' suffix in filenames
Nov 14, 2025
280c08f
fix: respect terminal width wrapping in help text
Nov 14, 2025
92816b7
fix(docs): correct command name in terraform deploy example
Nov 14, 2025
77e7a3c
docs: convert :::note purpose blocks to <Intro> components
Nov 14, 2025
57f4563
fix: add missing periods to comments per godot linter
Nov 14, 2025
38bfdb3
fix(security): use data masking layer in pager output
Nov 14, 2025
598da01
fix: make --force-color flag work for help text and version command
Nov 14, 2025
0d42696
fix: use UTF-8 box-drawing characters in tree command screengrabs
Nov 14, 2025
00441cb
fix: add tree package to Docker screengrab dependencies
Nov 14, 2025
e8031d6
chore: add screengrab dependencies and regenerate all screengrabs
Nov 14, 2025
ab1493e
fix: strip --charset=UTF-8 from tree screengrab filenames
Nov 14, 2025
3ddb6f0
chore: add blog posts and fix tree UTF-8 box-drawing characters in sc…
Nov 15, 2025
32ea54f
chore: add atmos auth command screengrabs to documentation
Nov 15, 2025
53d5fc5
chore: add atmos docs generate help screengrab
Nov 15, 2025
e7d2efc
chore(tests): regenerate all Help command snapshots
Nov 15, 2025
d046b05
fix: address CodeRabbit review comments
Nov 15, 2025
b6e2194
fix(cmd): properly align wrapped command descriptions in help output
Nov 15, 2025
fb37cb5
fix(docs): correct broken documentation links in blog posts
Nov 15, 2025
31d0114
fix(help): respect NO_COLOR and optimize config loading
Nov 15, 2025
92d14b3
fix: address CodeRabbit review comments
Nov 15, 2025
33b5519
test: fix test failures from formatting and output changes
Nov 15, 2025
7dced58
test: regenerate snapshots for config output and help text changes
Nov 15, 2025
9d25185
fix: preserve foreground colors in combined ANSI sequences
Nov 15, 2025
eb5a8a3
Merge branch 'main' into custom-planfile
osterman Nov 15, 2025
9f00759
perf: add performance tracking to renderFlags function
Nov 15, 2025
8a3f221
refactor: eliminate deep exit from pager error handling
Nov 16, 2025
c55b489
refactor: eliminate deep exit from version flag & add platform saniti…
Nov 16, 2025
7a1d91d
Merge branch 'main' into custom-planfile
osterman Nov 16, 2025
27a82db
test: regenerate snapshots with platform sanitization
Nov 16, 2025
0051dc7
fix: Ensure --version flag exits with code 0 in all scenarios
Nov 16, 2025
bf4c8c7
fix: Eliminate deep exit from version flag handling for Go 1.25 compa…
Nov 16, 2025
411d4f5
Merge branch 'main' into custom-planfile
Nov 17, 2025
d14ca87
fix: Ensure version command executes through normal Cobra flow for pr…
Nov 17, 2025
732453b
fix: Add platform sanitization to CLI help test snapshots
Nov 17, 2025
a741707
fix: Add platform sanitization to additional CLI help test snapshots
Nov 17, 2025
b599e57
test: improve coverage for help template and markdown rendering system
Nov 17, 2025
afc1532
test: add comprehensive tests for help template formatting functions
Nov 17, 2025
276285a
test: fix terraform generate varfile test to handle ANSI color codes
Nov 17, 2025
f7f3d5c
fix: improve I/O context error handling and add performance tracking
Nov 17, 2025
abea2f2
test: add comprehensive tests for root.go helper functions and pager …
Nov 17, 2025
b71ce43
test: add comprehensive tests for markdown styles configuration
Nov 17, 2025
7b8a7a8
fix: ensure NO_COLOR environment variable properly disables ANSI codes
Nov 17, 2025
452044f
fix: migrate terraform generate varfile to modern command pattern
Nov 17, 2025
80fe6e2
test: fix environment variable pollution in codeblock test
Nov 17, 2025
d5f0744
Merge branch 'main' into custom-planfile
osterman Nov 17, 2025
66b341c
fix: replace deprecated theme.Styles with theme.GetCurrentStyles() to…
osterman Nov 17, 2025
2fab1e8
docs: update blog posts for enhanced documentation and color output
osterman Nov 17, 2025
14c9669
fix: remove duplicate icons in validation messages
osterman Nov 17, 2025
f6100ab
refactor: use ui.Success/Error instead of manual theme styles
osterman Nov 17, 2025
010428a
fix: add carriage return before validation messages to overwrite spinner
osterman Nov 17, 2025
56cf685
feat: add ui.ClearLine() to properly clear terminal lines
osterman Nov 17, 2025
50f914b
fix: make ui.ClearLine a constant, not a function that writes
osterman Nov 17, 2025
1f13511
fix: restore ui.ClearLine() as a function that writes
osterman Nov 17, 2025
5bcfe09
fix: make ui.ClearLine() respect NO_COLOR and terminal capabilities
osterman Nov 17, 2025
8cde087
Merge branch 'main' into custom-planfile
osterman Nov 18, 2025
1c2ed78
fix: add diagnostics to NO_COLOR test to identify remaining ANSI codes
osterman Nov 18, 2025
88d468a
Merge branch 'main' into custom-planfile
osterman Nov 18, 2025
6603b7f
test: regenerate help command snapshots for updated output format
osterman Nov 18, 2025
5cbd89f
fix: detect NO_COLOR env var early in logger initialization
osterman Nov 21, 2025
aaf097f
Merge branch 'main' into custom-planfile
osterman Nov 21, 2025
158174f
fix: Add ui.SetColorProfile() to centralize color profile configuration
osterman Nov 22, 2025
ed0fa13
Merge branch 'main' into custom-planfile
osterman Nov 22, 2025
fe75ccc
test: Clean up dead code in color_test.go
osterman Nov 22, 2025
5a6b9a3
Merge branch 'main' into custom-planfile
osterman Nov 23, 2025
6d34d0b
test: regenerate auth login --help golden snapshot after merge
osterman Nov 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions demo/screengrabs/demo-stacks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,56 @@ atmos describe dependents --help
atmos describe stacks --help
atmos describe workflows --help
atmos docs --help
atmos list --help
atmos list components --help
atmos list metadata --help
atmos list settings --help
atmos list stacks --help
atmos list values --help
atmos list vars --help
atmos list workflows --help
atmos pro lock --help
atmos pro unlock --help
atmos terraform --help
atmos terraform apply --help
atmos terraform clean --help
atmos terraform console --help
atmos terraform deploy --help
atmos terraform destroy --help
atmos terraform fmt --help
atmos terraform force-unlock --help
atmos terraform generate --help
atmos terraform generate backend --help
atmos terraform generate backends --help
atmos terraform generate planfile --help
atmos terraform generate varfile --help
atmos terraform generate varfiles --help
atmos terraform get --help
atmos terraform graph --help
atmos terraform import --help
atmos terraform init --help
atmos terraform login --help
atmos terraform logout --help
atmos terraform metadata --help
atmos terraform modules --help
atmos terraform output --help
atmos terraform plan --help
atmos terraform plan-diff --help
atmos terraform providers --help
atmos terraform refresh --help
atmos terraform shell --help
atmos terraform show --help
atmos terraform state --help
atmos terraform taint --help
atmos terraform test --help
atmos terraform untaint --help
atmos terraform validate --help
atmos terraform version --help
atmos terraform workspace --help
atmos validate --help
atmos validate component --help
atmos validate editorconfig --help
atmos validate schema --help
atmos validate stacks --help
atmos vendor --help
atmos vendor pull --help
Expand Down
335 changes: 335 additions & 0 deletions website/docs/cli/commands/terraform/terraform-apply.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,335 @@
---
title: atmos terraform apply
sidebar_label: apply
sidebar_class_name: command
id: apply
---
import Screengrab from '@site/src/components/Screengrab'
import Terminal from '@site/src/components/Terminal'

:::note purpose
Use this command to apply Terraform changes for a component in an Atmos stack. This command can either generate a new plan and apply it, or apply a previously generated planfile.
:::

<Screengrab title="atmos terraform apply --help" slug="atmos-terraform-apply--help" />

## Usage

Execute the `terraform apply` command like this:

```shell
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`

:::tip
For automated deployments, consider using `atmos terraform deploy` which automatically includes `-auto-approve`.
:::

## Examples

### Interactive Apply

Apply changes interactively (you'll be prompted to approve):

```shell
atmos terraform apply vpc -s dev
```

### Apply from Previous Plan

Apply using the planfile generated by a previous `atmos terraform plan`:

```shell
# 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:

```shell
# 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):

```shell
atmos terraform apply vpc -s dev -auto-approve
```

### Targeted Apply

Apply changes only to specific resources:

```shell
atmos terraform apply vpc -s dev -target=aws_subnet.private
```

## 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:

```shell
# 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:

```shell
# 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:
1. Generate a new plan
2. Show the planned changes
3. Prompt for approval (unless `-auto-approve` is used)
4. Apply the changes if approved

```shell
atmos terraform apply vpc -s dev
```

## Arguments

<dl>
<dt>`component` <em>(required)</em></dt>
<dd>
Atmos component name to apply.
</dd>
</dl>

## Flags

<dl>
<dt>`--stack` / `-s` <em>(required)</em></dt>
<dd>
Atmos stack name where the component is defined.
</dd>

<dt>`--from-plan` <em>(optional)</em></dt>
<dd>
Apply the planfile previously generated by `atmos terraform plan`.

The planfile must exist in the component directory with the standard Atmos naming convention.

```shell
atmos terraform apply vpc -s dev --from-plan
```
</dd>

<dt>`--planfile` <em>(optional)</em></dt>
<dd>
Apply a specific planfile at the given path.

Use this instead of the native Terraform planfile argument.

```shell
atmos terraform apply vpc -s dev --planfile /path/to/plan.tfplan
```
</dd>

<dt>`--affected` <em>(optional)</em></dt>
<dd>
Apply only affected components based on changes in the repository.

```shell
atmos terraform apply --affected
```
</dd>

<dt>`--all` <em>(optional)</em></dt>
<dd>
Apply all components in all stacks (use with extreme caution).

```shell
atmos terraform apply --all
```
</dd>

<dt>`--dry-run` <em>(optional)</em></dt>
<dd>
Show what would be executed without actually running the apply.

```shell
atmos terraform apply vpc -s dev --dry-run
```
</dd>

<dt>`--skip-init` <em>(optional)</em></dt>
<dd>
Skip running `terraform init` before applying.

```shell
atmos terraform apply vpc -s dev --skip-init
```
</dd>

<dt>`--process-templates` <em>(optional)</em></dt>
<dd>
Enable/disable Go template processing in Atmos stack manifests.

Default: `true`

```shell
atmos terraform apply vpc -s dev --process-templates=false
```
</dd>
</dl>

## Native Terraform Flags

The `atmos terraform apply` command supports all native `terraform apply` flags. Some commonly used flags include:

<dl>
<dt>`-auto-approve`</dt>
<dd>
Apply changes without manual approval prompt.

```shell
atmos terraform apply vpc -s dev -auto-approve
```

:::warning
Use `-auto-approve` with caution, especially in production environments.
:::
</dd>

<dt>`-target=RESOURCE`</dt>
<dd>
Apply changes only to specific resources. Can be specified multiple times.

```shell
atmos terraform apply vpc -s dev -target=aws_subnet.private -target=aws_route_table.private
```
</dd>

<dt>`-var 'NAME=VALUE'`</dt>
<dd>
Set a variable value. Can be specified multiple times.

```shell
atmos terraform apply vpc -s dev -var="instance_count=3"
```
</dd>

<dt>`-refresh-only`</dt>
<dd>
Only update the state to match remote systems.

```shell
atmos terraform apply vpc -s dev -refresh-only
```
</dd>

<dt>`-replace=RESOURCE`</dt>
<dd>
Force replacement of a specific resource.

```shell
atmos terraform apply vpc -s dev -replace=aws_instance.web
```
</dd>
</dl>

## Best Practices

### Two-Stage Apply Process

For production environments, we recommend a two-stage apply process:

```shell
# 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:

1. Generate a plan in one job:
```shell
atmos terraform plan vpc -s prod -out=plan.tfplan
```

2. Apply the plan in another job (after approval):
```shell
atmos terraform apply vpc -s prod --planfile plan.tfplan
```

Or use `atmos terraform deploy` for fully automated deployments:
```shell
atmos terraform deploy vpc -s prod
```

## Related Commands

- [`atmos terraform plan`](/cli/commands/terraform/plan) - Generate an execution plan
- [`atmos terraform deploy`](/cli/commands/terraform/deploy) - Apply with auto-approval
- [`atmos terraform destroy`](/cli/commands/terraform/destroy) - Destroy infrastructure
- [`atmos terraform plan-diff`](/cli/commands/terraform/plan-diff) - Compare plan files

## Configuration

Configure default behavior for `terraform apply` in your `atmos.yaml`:

```yaml
components:
terraform:
# Auto-approve all applies (use with caution)
apply_auto_approve: false

# Auto-generate backend configuration
auto_generate_backend_file: true
```

:::info
See [Terraform Planfiles](/core-concepts/terraform/planfiles) for a comprehensive guide on working with planfiles in Atmos.
:::

:::note
The `atmos terraform apply` command supports all native `terraform apply` options described in [Terraform apply options](https://developer.hashicorp.com/terraform/cli/commands/apply#apply-options), except that planfile arguments should use `--from-plan` or `--planfile` flags instead of being passed directly.
:::
Loading
Loading