Skip to content

Comments

[Terragrunt] Add default Terragrunt Parser for Stdout, Consolidated output mode and Native Slack integration in Tfnotify#142

Merged
justushar merged 12 commits intomasterfrom
Terragrunt/Parser
Feb 5, 2026
Merged

[Terragrunt] Add default Terragrunt Parser for Stdout, Consolidated output mode and Native Slack integration in Tfnotify#142
justushar merged 12 commits intomasterfrom
Terragrunt/Parser

Conversation

@justushar
Copy link
Collaborator

@justushar justushar commented Dec 24, 2025

WHAT

Adds Terragrunt Parser and Terragrunt consolidated output mode for Plan operations to provide a single consolidated plan. Adds default support for Terragrunt run-all command in tfnotify.
The change also adds slack handler back into Tfnotify.
It can be used via the tfcmt configuration as follows:

slack:
  enabled: true
  notify_on_plan_error: true
  notify_on_apply_error: true
  use_threads: true
  plan_title: ":test_tube: E2E Test: Terraform Plan Failed"
  plan_message: "This is an automated E2E test for tfnotify Slack integration"
  apply_title: ":test_tube: E2E Test: Terraform Apply Failed"
  apply_message: "This is an automated E2E test for apply failure notifications"

Please note, the plan_title, plan_message, apply_title, apply_message as well as channel_id, and bot_token can be fetched directly from env variables.
(Write the change being made with this pull request)

WHY

For better UX in case of Terragrunt.
(Write the motivation why you submit this pull request)

@justushar justushar requested a review from j-njoto as a code owner December 24, 2025 07:14
The TerragruntParser was always calling ParseWithConsolidation with
consolidated=false, even when the --consolidated flag was set. This
prevented the consolidation logic from ever executing, resulting in
multiple separate comments instead of one consolidated comment.

Changes:
- Add Consolidated field to TerragruntParser struct
- Update NewTerragruntParser to accept consolidated parameter
- Modified Parse() to use p.Consolidated instead of hardcoded false
- Update plan.go and apply.go to pass true when consolidated mode enabled
- Fix test files to pass explicit false for non-consolidated tests

This fixes the issue where Terragrunt run-all would post separate
comments for each module instead of consolidating them into a single
comment when --consolidated flag is used.
…lidated mode

- Capture 'No changes' and 'Plan: X to add' summary lines
- Capture resource diff details (lines with +, -, ~, #)
- Capture terraform action headers
- Strip terragrunt prefix before appending to buffer

This fixes empty module summaries in consolidated comments.
…onsolidation

- Skip duplicate consecutive lines in module buffers
- Exclude root module '.' from consolidated output
- Prevent 'No changes' from appearing multiple times
@siroken3
Copy link
Member

siroken3 commented Feb 4, 2026

@justushar I think the Title and Description should include an explanation regarding the changes made for Slack.

@justushar justushar changed the title [Terragrunt] Add default Terragrunt Parser for Stdout, Consolidated output mode [Terragrunt] Add default Terragrunt Parser for Stdout, Consolidated output mode and Native Slack integration in Tfnotify Feb 5, 2026
@justushar justushar merged commit 692c2c5 into master Feb 5, 2026
3 of 5 checks passed
@justushar justushar deleted the Terragrunt/Parser branch February 5, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants