Skip to content

feat(terraform): add tflint hook and terraform lint command - #2675

Merged
Andriy Knysh (aknysh) merged 76 commits into
mainfrom
osterman/tf-lint-hook
Jul 23, 2026
Merged

Andriy Knysh (aknysh) merged 76 commits into
mainfrom
osterman/tf-lint-hook

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented Jul 1, 2026 •

Copy link
Copy Markdown
Member

what

  • Add a built-in tflint hook kind that lints Terraform/OpenTofu on lifecycle events with zero configuration (kind: tflint, defaults to after.terraform.plan).
  • Add a standalone atmos terraform lint CLI command (--all/--affected/single-component targeting) that runs TFLint once per unique component even when it's used by multiple stacks, instead of repeating the same lint for every stack.
  • Teach the shared hook CommandEngine an opt-in CaptureStdout mode: since tflint --format=sarif writes SARIF only to stdout (no file-output flag), the engine redirects the tool's stdout into the existing ATMOS_OUTPUT_FILE side channel.
  • Wire tflint through the shared sarif result handler so findings render in the terminal, Atmos Pro, and — in CI — as a step summary, inline PR annotations, and a GitHub Code Scanning upload, exactly like the existing scanner kinds.
  • Ship the full release surface: examples/hooks-tflint, a kind: tflint docs section in stacks/hooks.mdx, atmos terraform lint CLI docs, a changelog blog post, and a roadmap milestone.

why

  • terraform validate misses lint-class problems (unused declarations, deprecated syntax, invalid provider/instance settings); Atmos had built-in security/cost scanner kinds but no linter kind.
  • tflint's stdout-only SARIF output was the one gap preventing full parity; a small, opt-in engine capture closes it without touching the other kinds (trivy/checkov/kics/infracost keep streaming stdout).
  • Reusing the shared SARIF handler means tflint inherits the native-CI integration (annotations + Code Scanning) with no tflint-specific wiring.
  • Components shared across many stacks would otherwise get linted once per stack; the standalone command dedupes by component so CI cost doesn't scale with stack count.

references

Summary by CodeRabbit

  • New Features
    • Added atmos terraform lint with --all/--affected, --stack, --error-mode, --max-findings, and markdown/rich output.
    • Introduced built-in tflint hook kind and a tflint workflow step that consumes SARIF emitted to stdout.
    • Workflow steps now support an args field in addition to with.
  • Bug Fixes
    • Improved SARIF handling for missing/empty capture files and ensured stdout-emitted SARIF produces scan artifacts.
    • Fixed --identity=false Terraform lint to avoid evaluating unauthenticated YAML/function values.
  • Documentation
    • Added tflint/Terraform lint docs plus blog content and runnable hook/lint examples.
  • Style
    • Improved SARIF badge/link rendering (including plain mode) and made spinners safe to truncate.

Add a `tflint` scanner hook kind that lints Terraform/OpenTofu on lifecycle
events with zero configuration. Because `tflint --format=sarif` writes SARIF
only to stdout (no file-output flag), the shared CommandEngine gains an
opt-in `CaptureStdout` mode that redirects the subprocess's stdout into the
existing ATMOS_OUTPUT_FILE side channel; stderr still streams. tflint then
rides the shared sarif result handler, so findings render in the terminal,
Atmos Pro, and — in CI — as a step summary, inline PR annotations, and a
GitHub Code Scanning upload, identical to trivy/checkov/kics.

Ships the example (examples/hooks-tflint), docs (kind: tflint section),
changelog blog post, and a roadmap milestone.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@atmos-pro

atmos-pro Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@osterman Erik Osterman (Cloud Posse) (osterman) added the minor New features that do not break anything label Jul 1, 2026
@github-actions github-actions Bot added the size/m Medium size PR label Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

  • .github/workflows/test.yml

@github-actions

github-actions Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Resource Changes Found for bucket in test

Atmos CI

create

Plan: 4 to add, 0 to change, 0 to destroy.
To reproduce this locally, run:

atmos terraform plan bucket -s test

Create

+ aws_s3_bucket.checkov_target
+ aws_s3_bucket.this
+ aws_s3_bucket.trivy_target
+ aws_s3_bucket_public_access_block.trivy_target
Terraform Plan Summary
  # aws_s3_bucket.checkov_target will be created
  + resource "aws_s3_bucket" "checkov_target" {
      + acceleration_status         = (known after apply)
      + acl                         = (known after apply)
      + arn                         = (known after apply)
      + bucket                      = "atmos-native-ci-e2e-checkov-test"
      + bucket_domain_name          = (known after apply)
      + bucket_prefix               = (known after apply)
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = false
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + object_lock_enabled         = (known after apply)
      + policy                      = (known after apply)
      + region                      = (known after apply)
      + request_payer               = (known after apply)
      + tags_all                    = (known after apply)
      + website_domain              = (known after apply)
      + website_endpoint            = (known after apply)

      + cors_rule (known after apply)

      + grant (known after apply)

      + lifecycle_rule (known after apply)

      + logging (known after apply)

      + object_lock_configuration (known after apply)

      + replication_configuration (known after apply)

      + server_side_encryption_configuration (known after apply)

      + versioning (known after apply)

      + website (known after apply)
    }

  # aws_s3_bucket.this will be created
  + resource "aws_s3_bucket" "this" {
      + acceleration_status         = (known after apply)
      + acl                         = (known after apply)
      + arn                         = (known after apply)
      + bucket                      = "atmos-native-ci-e2e-test"
      + bucket_domain_name          = (known after apply)
      + bucket_prefix               = (known after apply)
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = false
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + object_lock_enabled         = (known after apply)
      + policy                      = (known after apply)
      + region                      = (known after apply)
      + request_payer               = (known after apply)
      + tags                        = {
          + "AtmosFixture" = "native-ci-e2e"
          + "Stage"        = "test"
        }
      + tags_all                    = {
          + "AtmosFixture" = "native-ci-e2e"
          + "Stage"        = "test"
        }
      + website_domain              = (known after apply)
      + website_endpoint            = (known after apply)

      + cors_rule (known after apply)

      + grant (known after apply)

      + lifecycle_rule (known after apply)

      + logging (known after apply)

      + object_lock_configuration (known after apply)

      + replication_configuration (known after apply)

      + server_side_encryption_configuration (known after apply)

      + versioning (known after apply)

      + website (known after apply)
    }

  # aws_s3_bucket.trivy_target will be created
  + resource "aws_s3_bucket" "trivy_target" {
      + acceleration_status         = (known after apply)
      + acl                         = (known after apply)
      + arn                         = (known after apply)
      + bucket                      = "atmos-native-ci-e2e-trivy-test"
      + bucket_domain_name          = (known after apply)
      + bucket_prefix               = (known after apply)
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = false
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + object_lock_enabled         = (known after apply)
      + policy                      = (known after apply)
      + region                      = (known after apply)
      + request_payer               = (known after apply)
      + tags_all                    = (known after apply)
      + website_domain              = (known after apply)
      + website_endpoint            = (known after apply)

      + cors_rule (known after apply)

      + grant (known after apply)

      + lifecycle_rule (known after apply)

      + logging (known after apply)

      + object_lock_configuration (known after apply)

      + replication_configuration (known after apply)

      + server_side_encryption_configuration (known after apply)

      + versioning (known after apply)

      + website (known after apply)
    }

  # aws_s3_bucket_public_access_block.trivy_target will be created
  + resource "aws_s3_bucket_public_access_block" "trivy_target" {
      + block_public_acls       = true
      + block_public_policy     = true
      + bucket                  = (known after apply)
      + id                      = (known after apply)
      + ignore_public_acls      = true
      + restrict_public_buckets = true
    }

Plan: 4 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + bucket_name = "atmos-native-ci-e2e-test"

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ecc3d76e-1864-4953-a71c-a226033ccfe1

📥 Commits

Reviewing files that changed from the base of the PR and between a2fdee7 and 87579a0.

📒 Files selected for processing (2)
  • cmd/cmd_utils.go
  • internal/exec/workflow_utils.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • cmd/cmd_utils.go
  • internal/exec/workflow_utils.go

📝 Walkthrough

Walkthrough

Adds built-in TFLint scanning through hooks, workflow steps, and atmos terraform lint, with SARIF parsing, stdout capture, CI reporting, examples, schemas, tests, documentation, and supporting CI/toolchain updates.

Changes

Terraform linting and TFLint integration

Layer / File(s) Summary
Scanner runtime and SARIF pipeline
pkg/scanners/..., pkg/scanners/sarif/...
Adds scanner execution, binary resolution, stdout capture, SARIF parsing, path normalization, Markdown rendering, and CI annotations/results publishing.
TFLint scanner and CLI execution
pkg/scanners/tflint/..., cmd/terraform/lint.go, pkg/schema/schema.go
Adds TFLint configuration discovery, direct and affected-component execution, target deduplication, component provisioning, and Terraform lint configuration.
Hook and workflow integration
pkg/hooks/..., pkg/runner/step/..., internal/exec/..., cmd/cmd_utils.go
Registers the tflint hook kind, supports captured stdout, adds the TFLint workflow step, and supplies component, stack, Atmos configuration, authentication, and toolchain context.
Schemas, examples, tests, and documentation
pkg/schema/..., examples/..., tests/..., website/..., agent-skills/...
Adds generic workflow with and args handling, runnable examples, fixtures, command snapshots, tests, guides, and reference documentation.
Supporting maintenance
.github/..., pkg/toolchain/verification/..., lychee.toml, tests/preconditions.go
Updates CI setup, Terraform verification, provider-registry skips, link checking, Colima readiness, and GitHub attestation retries.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

  • cloudposse/atmos#2710: Adds schema-coverage ratchet tests for workflow-step fields, directly connecting to this change’s args and with schema support.

Suggested reviewers: aknysh

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.54% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a TFLint hook and a Terraform lint command.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch osterman/tf-lint-hook

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
pkg/hooks/command_engine_test.go (1)

113-182: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consolidate runEngine/runEngineWithKind and table-drive the two new tests.

runEngineWithKind (lines 113-130) duplicates runEngine (lines 26-46) almost verbatim, differing only in how kind is built. Also, TestCommandEngine_CaptureStdoutWritesToOutputFile and TestCommandEngine_NoCaptureStdoutLeavesOutputFileEmpty are the same scenario varying only CaptureStdout — a good fit for a table-driven test. As per coding guidelines, **/*_test.go: "Use table-driven tests for testing multiple scenarios in Go."

♻️ Suggested consolidation
 func runEngine(t *testing.T, hook *Hook) (*Output, error) {
 	t.Helper()
 	kind := &Kind{
 		Name:      "command",
 		OnFailure: OnFailureWarn,
 		Engine:    &CommandEngine{},
 	}
-	resolved := kind.ResolveDefaults(hook)
-	ctx := &ExecContext{
-		Hook: resolved,
-		Kind: kind,
-		AtmosConfig: &schema.AtmosConfiguration{
-			TerraformDirAbsolutePath: t.TempDir(),
-		},
-		Info: &schema.ConfigAndStacksInfo{
-			Stack:            "test-stack",
-			ComponentFromArg: "test-component",
-		},
-	}
-	return kind.Engine.Run(ctx)
+	return runEngineWithKind(t, kind, hook)
 }
-func TestCommandEngine_CaptureStdoutWritesToOutputFile(t *testing.T) {
-	...
-}
-
-func TestCommandEngine_NoCaptureStdoutLeavesOutputFileEmpty(t *testing.T) {
-	...
-}
+func TestCommandEngine_CaptureStdout(t *testing.T) {
+	cases := []struct {
+		name          string
+		captureStdout bool
+		body          string
+		wantArtifact  bool
+	}{
+		{"captures stdout into output file", true, `{"runs":[{"tool":{"driver":{"name":"tflint"}}}]}`, true},
+		{"leaves output file empty", false, "should not be captured", false},
+	}
+	for _, tc := range cases {
+		t.Run(tc.name, func(t *testing.T) {
+			exe := testExePath(t)
+			kind := &Kind{Name: "command", OnFailure: OnFailureWarn, Engine: &CommandEngine{}, CaptureStdout: tc.captureStdout}
+			hook := &Hook{
+				Kind:    "command",
+				Command: exe,
+				Args:    []string{"-test.run", "^$"},
+				Env: map[string]string{
+					"_ATMOS_TEST_ECHO_STDOUT": "1",
+					"_ATMOS_TEST_STDOUT_BODY": tc.body,
+				},
+			}
+			out, err := runEngineWithKind(t, kind, hook)
+			require.NoError(t, err)
+			if tc.wantArtifact {
+				require.NotNil(t, out.Artifact)
+				assert.Equal(t, tc.body, string(out.Artifact.Body))
+			} else {
+				assert.Nil(t, out.Artifact)
+			}
+		})
+	}
+}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/hooks/command_engine_test.go` around lines 113 - 182, `runEngineWithKind`
is duplicating `runEngine` with only the `Kind` setup differing, so consolidate
the shared setup into one helper and let both callers reuse it via
`CommandEngine`/`ExecContext` preparation. Also combine
`TestCommandEngine_CaptureStdoutWritesToOutputFile` and
`TestCommandEngine_NoCaptureStdoutLeavesOutputFileEmpty` into a table-driven
test that varies only `CaptureStdout` on `Kind` while keeping the shared `Hook`,
`testExePath`, and stdout body setup in one place.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/hooks-tflint/stacks/deploy/test.yaml`:
- Around line 16-20: The hook event name is using the hyphenated form instead of
the documented dotted form, so the tflint hook in the `hooks.lint.events` list
will not trigger as intended. Update the event value in this test fixture to
match the same `after.terraform.plan` identifier used elsewhere in the PR,
keeping the change localized to the `hooks` configuration for the `lint` entry.

In `@pkg/hooks/command_engine.go`:
- Around line 216-234: The hook stdout capture failure in runSubprocess
currently uses a dynamic fmt.Errorf message, which violates the static error
requirement. Update the os.Create failure path to return the appropriate
predefined error from errors/errors.go using the same errUtils.Build style used
in resolveBinaryOnPath, and preserve the underlying create error as the wrapped
cause. Keep the fix localized to runSubprocess and ensure the returned error is
constructed from a static error identifier rather than a raw formatted string.

---

Nitpick comments:
In `@pkg/hooks/command_engine_test.go`:
- Around line 113-182: `runEngineWithKind` is duplicating `runEngine` with only
the `Kind` setup differing, so consolidate the shared setup into one helper and
let both callers reuse it via `CommandEngine`/`ExecContext` preparation. Also
combine `TestCommandEngine_CaptureStdoutWritesToOutputFile` and
`TestCommandEngine_NoCaptureStdoutLeavesOutputFileEmpty` into a table-driven
test that varies only `CaptureStdout` on `Kind` while keeping the shared `Hook`,
`testExePath`, and stdout body setup in one place.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fa854da5-d496-4731-bbd6-341c3d30714b

📥 Commits

Reviewing files that changed from the base of the PR and between 17256ac and 22a7292.

📒 Files selected for processing (16)
  • cmd/terraform/hooks_kinds.go
  • examples/hooks-tflint/README.md
  • examples/hooks-tflint/atmos.yaml
  • examples/hooks-tflint/components/terraform/bucket/main.tf
  • examples/hooks-tflint/components/terraform/bucket/variables.tf
  • examples/hooks-tflint/components/terraform/bucket/versions.tf
  • examples/hooks-tflint/stacks/deploy/test.yaml
  • pkg/hooks/command_engine.go
  • pkg/hooks/command_engine_test.go
  • pkg/hooks/kind.go
  • pkg/hooks/kinds/tflint/kind.go
  • pkg/hooks/kinds/tflint/kind_test.go
  • pkg/hooks/main_test.go
  • website/blog/2026-07-01-tflint-hook-kind.mdx
  • website/docs/stacks/hooks.mdx
  • website/src/data/roadmap.js

Comment thread pkg/hooks/command_engine.go Resolved
@codecov

codecov Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.01984% with 302 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.78%. Comparing base (6426ad2) to head (87579a0).

Files with missing lines Patch % Lines
pkg/scanners/tflint/command.go 67.14% 57 Missing and 12 partials ⚠️
cmd/terraform/lint.go 58.27% 59 Missing and 4 partials ⚠️
cmd/cmd_utils.go 24.13% 20 Missing and 2 partials ⚠️
pkg/runner/step/tflint.go 81.98% 10 Missing and 10 partials ⚠️
pkg/scanners/sarif/normalize.go 89.89% 10 Missing and 9 partials ⚠️
internal/exec/workflow_utils.go 33.33% 16 Missing and 2 partials ⚠️
pkg/scanners/sarif_report.go 88.51% 9 Missing and 8 partials ⚠️
pkg/ui/spinner/spinner.go 48.48% 15 Missing and 2 partials ⚠️
pkg/scanners/runner.go 93.41% 8 Missing and 8 partials ⚠️
pkg/scanners/sarif/handler.go 93.87% 7 Missing and 2 partials ⚠️
... and 11 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2675      +/-   ##
==========================================
+ Coverage   81.72%   81.78%   +0.05%     
==========================================
  Files        1779     1791      +12     
  Lines      170835   172737    +1902     
==========================================
+ Hits       139615   141270    +1655     
- Misses      23493    23667     +174     
- Partials     7727     7800      +73     
Flag Coverage Δ
unittests 81.78% <85.01%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
errors/errors.go 100.00% <ø> (ø)
...ternal/exec/describe_stacks_component_processor.go 95.81% <100.00%> (+0.06%) ⬆️
internal/exec/terraform_affected.go 85.81% <100.00%> (+0.96%) ⬆️
internal/exec/yaml_func_terraform_state.go 93.84% <100.00%> (+0.19%) ⬆️
internal/exec/yaml_func_utils.go 82.85% <100.00%> (ø)
pkg/hooks/kind.go 100.00% <ø> (ø)
pkg/hooks/sarif/handler.go 93.51% <100.00%> (+0.06%) ⬆️
pkg/hooks/sarif/markdown.go 90.59% <100.00%> (+3.38%) ⬆️
pkg/hooks/sarif/normalize.go 88.29% <100.00%> (+0.94%) ⬆️
pkg/runner/step/variables.go 93.79% <100.00%> (+0.43%) ⬆️
... and 30 more

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…ue-forward docs

- Use static errUtils.ErrCreateFile (new sentinel) for the stdout-capture
  create failure instead of a raw fmt.Errorf (CodeRabbit; CLAUDE.md mandates
  static errors).
- examples/hooks-tflint: fire the hook on `before.terraform.init` (dotted,
  matching sibling examples) so linting fails fast before any init/plan work.
- examples/hooks-tflint: drop the fake AWS provider + S3 bucket; a linter needs
  no cloud provider or credentials. Component is now a provider-free
  `terraform_data` resource (renamed bucket -> example) that lints and plans
  fully offline; an intentionally-unused variable yields a deterministic finding.
- Docs/blog: lead with the value a linter brings — code consistency, enforced
  conventions, and hygiene (unused declarations, deprecated syntax) — and use
  the before-init event.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
website/docs/stacks/hooks.mdx (1)

856-857: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Scanner count is now stale.

This section still says "the three built-in SARIF scanners — checkov, trivy, kics — all participate", but Line 248 in this same doc was correctly updated to list four (trivy, checkov, kics, tflint). Update this line to include tflint too, for consistency.

📝 Proposed fix
-the hook or the terraform command. Outside CI they no-op. Findings derive from the
-tool's SARIF, so the three built-in SARIF scanners — `checkov`, `trivy`, `kics` —
-all participate; `infracost` (cost, not findings) does not.
+the hook or the terraform command. Outside CI they no-op. Findings derive from the
+tool's SARIF, so the four built-in SARIF scanners — `checkov`, `trivy`, `kics`,
+`tflint` — all participate; `infracost` (cost, not findings) does not.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@website/docs/stacks/hooks.mdx` around lines 856 - 857, The scanner list in
the hooks documentation is stale: the sentence in the SARIF section still names
only three built-in scanners. Update the text in the relevant docs block to
match the current set used elsewhere in this file by including `tflint`
alongside `checkov`, `trivy`, and `kics`, keeping the wording consistent with
the existing SARIF scanner references.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@website/docs/stacks/hooks.mdx`:
- Around line 856-857: The scanner list in the hooks documentation is stale: the
sentence in the SARIF section still names only three built-in scanners. Update
the text in the relevant docs block to match the current set used elsewhere in
this file by including `tflint` alongside `checkov`, `trivy`, and `kics`,
keeping the wording consistent with the existing SARIF scanner references.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f0e4ef13-b0b6-4401-a616-4c58a7e0ecbe

📥 Commits

Reviewing files that changed from the base of the PR and between 22a7292 and 851e8c3.

📒 Files selected for processing (9)
  • errors/errors.go
  • examples/hooks-tflint/README.md
  • examples/hooks-tflint/components/terraform/example/main.tf
  • examples/hooks-tflint/components/terraform/example/variables.tf
  • examples/hooks-tflint/components/terraform/example/versions.tf
  • examples/hooks-tflint/stacks/deploy/test.yaml
  • pkg/hooks/command_engine.go
  • website/blog/2026-07-01-tflint-hook-kind.mdx
  • website/docs/stacks/hooks.mdx
🚧 Files skipped from review as they are similar to previous changes (2)
  • examples/hooks-tflint/stacks/deploy/test.yaml
  • pkg/hooks/command_engine.go

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 1, 2026
Adds a tflint hook (kind: tflint) to the native-ci-e2e scenario so tflint is
exercised end-to-end in CI at parity with checkov/trivy/kics — its stdout SARIF
flows through the native-CI outputs (step summary, PR annotations, Code
Scanning). The hook fires on before-terraform-init (a linter should fail fast),
is scoped with --filter=tflint_target.tf, and auto-installs via
dependencies.tools (tflint 0.59.1, resolved from the aqua-public registry like
checkov). tflint_target.tf declares an unused local that trips the builtin
terraform_unused_declarations rule; it is inert for Terraform so it still
applies cleanly against the Floci emulator.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 2, 2026
@github-advanced-security

Copy link
Copy Markdown
Contributor

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

1 similar comment
@github-advanced-security

Copy link
Copy Markdown
Contributor

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@github-actions

github-actions Bot commented Jul 2, 2026 •

Copy link
Copy Markdown

Note

SHA Pin Verification Passed ✅

All 133 third-party action reference(s) are SHA-pinned (128 tag-verified, 5 branch-pinned).

@mergify

mergify Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Important

Cloud Posse Engineering Team Review Required

This pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes.

To expedite this process, reach out to us on Slack in the #pr-reviews channel.

@mergify mergify Bot added the needs-cloudposse Needs Cloud Posse assistance label Jul 2, 2026
The numbered-list continuation lines in the terraform-lint auth-disabled
fix writeup used 3-space indentation (aligned to the "1. " marker width),
which violates this repo's .editorconfig indent_size=2 rule for *.md
files and failed the native `atmos validate editorconfig --affected`
check in CI.

Verified locally with the same command CI runs:
atmos validate editorconfig --affected --base origin/main

Co-Authored-By: Claude Sonnet 5 <[email protected]>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 21, 2026
@mergify

mergify Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
internal/exec/validate_stacks.go (1)

288-303: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use lo.Uniq for the validation errors.

github.com/samber/lo is already a dependency and this package already uses it, so validationErrorMessages = lo.Uniq(validationErrorMessages) avoids the small redundant helper while keeping first-seen order.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/exec/validate_stacks.go` around lines 288 - 303, Replace the local
deduplication helper `dedupeStrings` with `lo.Uniq` when processing
`validationErrorMessages`, preserving first-seen order and removing the
now-unused helper.
cmd/terraform/lint.go (1)

240-285: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Per-stack-file OnProgress updates may flood CI logs on large repos.

errOptions.OnProgress fires once per stack file (before filtering). In non-TTY mode — the primary environment this PR's CI-facing lint command targets — spinner.Update falls back to ui.Info(message) per call, so a monorepo with hundreds of stack files prints hundreds of "Discovering..." lines to CI logs. Consider throttling (e.g. every Nth file, or a time-based interval) or skipping progress reporting entirely when not a TTY.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/terraform/lint.go` around lines 240 - 285, Throttle or disable the
per-stack-file progress reporting configured in terraformLintDescribeStacks,
especially for non-TTY output where spinner.Update emits one CI log line per
callback. Preserve progress feedback for interactive terminals while limiting
updates to a reasonable interval or batch size, and ensure the final
success/error messages remain unchanged.
pkg/hooks/sarif/normalize.go (1)

266-296: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

githubBlobBaseURL duplicated verbatim across hooks/sarif and scanners/sarif. Same consts, same sync.Once guard, same body — one shared root cause: this GitHub Actions URL-construction logic was written twice instead of once.

  • pkg/hooks/sarif/normalize.go#L266-L296: extract this block to a small shared helper (e.g. a common internal package importable by both pkg/hooks/sarif and pkg/scanners/sarif) and have this file call it.
  • pkg/scanners/sarif/normalize.go#L266-L295: remove this identical copy and call the same shared helper instead of re-declaring the consts/sync.Once/function.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/hooks/sarif/normalize.go` around lines 266 - 296, The GitHub Actions blob
URL logic is duplicated across both SARIF normalizers. Extract the constants,
sync.Once environment binding, and URL construction from githubBlobBaseURL into
a shared internal helper importable by both packages; update
pkg/hooks/sarif/normalize.go lines 266-296 to call it, and remove the duplicate
declarations and implementation from pkg/scanners/sarif/normalize.go lines
266-295 so its githubBlobBaseURL flow uses the same helper.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/scanners/tflint/tflint.go`:
- Around line 25-36: Update tflint.DefaultArgs() to replace the positional
$ATMOS_COMPONENT_PATH argument with --chdir=$ATMOS_COMPONENT_PATH. Adjust the
corresponding default-argument assertions in the TFLint scanner and hook kind
tests to expect the new flag form.

In `@pkg/ui/spinner/spinner.go`:
- Around line 329-330: Update the width field comments in both
dynamicSpinnerModel and manualSpinnerModel to reflect that width is initialized
synchronously via initialWidth(), rather than remaining zero until the first
resize event; keep the comments consistent with spinnerModel.width.

---

Nitpick comments:
In `@cmd/terraform/lint.go`:
- Around line 240-285: Throttle or disable the per-stack-file progress reporting
configured in terraformLintDescribeStacks, especially for non-TTY output where
spinner.Update emits one CI log line per callback. Preserve progress feedback
for interactive terminals while limiting updates to a reasonable interval or
batch size, and ensure the final success/error messages remain unchanged.

In `@internal/exec/validate_stacks.go`:
- Around line 288-303: Replace the local deduplication helper `dedupeStrings`
with `lo.Uniq` when processing `validationErrorMessages`, preserving first-seen
order and removing the now-unused helper.

In `@pkg/hooks/sarif/normalize.go`:
- Around line 266-296: The GitHub Actions blob URL logic is duplicated across
both SARIF normalizers. Extract the constants, sync.Once environment binding,
and URL construction from githubBlobBaseURL into a shared internal helper
importable by both packages; update pkg/hooks/sarif/normalize.go lines 266-296
to call it, and remove the duplicate declarations and implementation from
pkg/scanners/sarif/normalize.go lines 266-295 so its githubBlobBaseURL flow uses
the same helper.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1492a94b-1bdb-4f2e-a536-2484b2289aee

📥 Commits

Reviewing files that changed from the base of the PR and between a812078 and adcbcc9.

📒 Files selected for processing (43)
  • cmd/terraform/lint.go
  • cmd/terraform/lint_test.go
  • internal/exec/describe_stacks.go
  • internal/exec/describe_stacks_component_processor.go
  • internal/exec/describe_stacks_component_processor_auth_test.go
  • internal/exec/stack_processor_utils.go
  • internal/exec/terraform_affected.go
  • internal/exec/validate_stacks.go
  • internal/exec/yaml_func_terraform_state.go
  • internal/exec/yaml_func_terraform_state_yq_defaults_test.go
  • internal/exec/yaml_func_utils.go
  • internal/exec/yaml_func_utils_lenient_test.go
  • pkg/datafetcher/schema/atmos/config/1.0.json
  • pkg/datafetcher/schema/atmos/manifest/1.0.json
  • pkg/hooks/command_engine.go
  • pkg/hooks/kinds/tflint/kind_test.go
  • pkg/hooks/sarif/handler.go
  • pkg/hooks/sarif/handler_test.go
  • pkg/hooks/sarif/markdown.go
  • pkg/hooks/sarif/markdown_test.go
  • pkg/hooks/sarif/normalize.go
  • pkg/hooks/sarif/normalize_test.go
  • pkg/hooks/sarif/sarif_test.go
  • pkg/scanners/runner.go
  • pkg/scanners/runner_test.go
  • pkg/scanners/sarif/handler.go
  • pkg/scanners/sarif/handler_test.go
  • pkg/scanners/sarif/markdown.go
  • pkg/scanners/sarif/markdown_test.go
  • pkg/scanners/sarif/normalize.go
  • pkg/scanners/sarif/normalize_test.go
  • pkg/scanners/sarif/rich_test.go
  • pkg/scanners/sarif/sarif.go
  • pkg/scanners/sarif/sarif_test.go
  • pkg/scanners/tflint/command.go
  • pkg/scanners/tflint/command_test.go
  • pkg/scanners/tflint/tflint.go
  • pkg/scanners/tflint/tflint_test.go
  • pkg/scanners/types.go
  • pkg/schema/schema.go
  • pkg/terraform/generate/file_generator.go
  • pkg/terraform/generate/file_generator_test.go
  • pkg/ui/spinner/spinner.go
🚧 Files skipped from review as they are similar to previous changes (9)
  • pkg/hooks/command_engine.go
  • pkg/scanners/types.go
  • internal/exec/terraform_affected.go
  • pkg/scanners/sarif/normalize_test.go
  • pkg/scanners/runner_test.go
  • pkg/scanners/sarif/sarif.go
  • pkg/scanners/runner.go
  • pkg/scanners/sarif/handler_test.go
  • pkg/scanners/sarif/sarif_test.go

Comment thread pkg/scanners/tflint/tflint.go Resolved
Comment thread pkg/ui/spinner/spinner.go Resolved
# Conflicts:
#	internal/exec/yaml_func_utils.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/auth/config_helpers.go`:
- Around line 178-183: Update the identity selection logic around
resolveComponentIdentityMarker to resolve global identity names through
IdentityCaseMap rather than an exact map lookup, with the appropriate fallback
when no case-insensitive match exists. Use the resolved canonical name when
reading and writing normalizedIdentities so markers such as “IDENTITY” correctly
target the configured “identity” entry and preserve both true and false
selections.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e7cde610-9e6f-4fe4-a98c-1d9ec28fc510

📥 Commits

Reviewing files that changed from the base of the PR and between adcbcc9 and d51c749.

📒 Files selected for processing (4)
  • errors/errors.go
  • internal/exec/stack_processor_utils.go
  • internal/exec/yaml_func_utils.go
  • pkg/auth/config_helpers.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/exec/stack_processor_utils.go
  • internal/exec/yaml_func_utils.go

Comment thread pkg/auth/config_helpers.go Resolved
…directory arg

TFLint 0.47+ removed support for positional [FILE or DIR...] arguments
("Command line arguments support was dropped in v0.47. Use --chdir or
--filter instead."). CI pins tflint 0.59.1, so every lint run was hitting
this error instead of producing real findings. Verified directly against
0.59.1: the positional form errors immediately, --chdir works.

Fixing this surfaced a second bug: --chdir reports paths relative to the
scanning process's own cwd rather than the target directory, so the
Location column's component-relative shortening (which only handled
absolute paths) stopped working. shortenToComponent now resolves relative
paths against the process cwd before comparing.

Also fixes two stale spinner.go field comments (still said width was
"0 until the first resize event" after initialWidth() started seeding it
synchronously at construction).

Addresses CodeRabbit review comments on PR #2675.
atmos validate stacks was rejecting the native-ci-e2e fixture's `kind:
tflint` hook with "value must be one of \"store\", \"command\", ...\"
ci.download\"" — the manifest and stack-config JSON schemas' hooks.<name>.kind
enum was never updated when the tflint hook kind was added, so CI's
[native ci] terraform plan job failed at the validate-stacks step before
ever reaching the lint itself.
…inal color test

pkg/runner/step/tflint_test.go asserted a "--chdir" before "--format=sarif"
argument order that never matched pkg/scanners/tflint.DefaultArgs()'s actual
output (format first) — these two tests were failing on both the linux and
macos acceptance-test jobs.

TestHandler_RichTerminalBodyIncludesSourceExcerpt asserted a literal,
uncolored "[tflint] variables.tf:2:10" substring, but richStyle wraps each
segment in its own ANSI codes when the terminal's color profile is detected
as color-capable — which some CI runners' non-TTY output apparently is.
Force NO_COLOR for that test so the assertion is hermetic instead of
environment-dependent.
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 23, 2026
resolveComponentIdentityMarker looked up globalAuth.Identities[identityName]
with the component marker's own casing. Viper lower-cases config keys during
load, so a marker spelled "IDENTITY" never matched a globally-configured
"identity" entry, even though they're the same identity — the marker was
incorrectly treated as undefined (dropped if default:false, rejected if
default:true).

Resolve through globalAuth.IdentityCaseMap when an exact match misses, and
write the marker's outcome back under the identity's own canonical key so it
overrides the existing entry instead of creating a separate, differently-cased
one. Extracted as resolveGlobalIdentityKey to keep the caller flat (nestif).

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/auth/config_helpers_test.go`:
- Around line 350-395: Update the “true marker” and “false marker” tests in the
MergeComponentAuthFromConfig coverage to use a mixed-case global identity key
such as “Identity”, with IdentityCaseMap mapping “identity” to “Identity” and
the component configuration retaining the lowercase marker. Assert the marker
updates mergedAuth.Identities["Identity"], preserves its Kind, applies both
boolean values through a table-driven test, and does not create
mergedAuth.Identities["identity"].
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ffb7c23d-f136-4a53-8ea0-2c79e8e1c80d

📥 Commits

Reviewing files that changed from the base of the PR and between 1ee7788 and 16c7c40.

📒 Files selected for processing (2)
  • pkg/auth/config_helpers.go
  • pkg/auth/config_helpers_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/auth/config_helpers.go

Comment thread pkg/auth/config_helpers_test.go Resolved
The test hardcoded Unix-style "/repo/..." paths for both file and
componentDir. filepath.IsAbs requires a volume name (drive letter or UNC)
on Windows, so these strings aren't absolute there — the component-relative
shortening locationCell/shortenToComponent exercises never engaged, and
every subtest returned the full path unchanged instead of the shortened
form, failing on windows-latest.

Build componentDir/file from t.TempDir() (real, platform-correct absolute
paths), matching the pattern already used correctly by the adjacent
TestLocationCell_ComponentRelative_ChdirRelativePath test.
TestMergeComponentAuthFromConfig_DefaultOnlyMarkerCaseInsensitiveMatch used
IdentityCaseMap["identity"] == "identity", making case-map resolution
indistinguishable from an exact/already-lowercase match — an exact-match
regression in resolveGlobalIdentityKey wouldn't have failed this test.

Use a genuinely mixed-case global identity key ("Identity", distinct from
both the IdentityCaseMap's lowercase key and the marker's own casing), so
the assertion can only pass by actually resolving through IdentityCaseMap.
Converted to table-driven per the repo's Go test convention.

Addresses CodeRabbit review comment on PR #2675.
@atmos-pro

atmos-pro Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@github-actions

Copy link
Copy Markdown

Warning

Release Documentation Required

This PR is labeled minor or major and requires documentation updates:

  • Changelog entry - Add a blog post in website/blog/YYYY-MM-DD-feature-name.mdx
  • Roadmap update - Update website/src/data/roadmap.js with the new milestone

Alternatively: If this change doesn't require release documentation, remove the minor or major label.

@github-actions

Copy link
Copy Markdown

These changes were released in v1.224.0.

This branch was successfully deployed

1 active and 1 inactive deployments
preview — 87579a05 Deployed Jul 23, 2026 by github-actions[bot]
screengrabs — 87579a05 Deployed Jul 23, 2026 by aknysh via build #557
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor New features that do not break anything size/xl Extra large size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants