Schedule icon
TerragruntCLI icon
Script icon
Process icon
SlackIncomingWebhook icon
DiscordIncomingWebhook icon

Weekly Terragrunt Output Inventory Across Every Unit

Build a weekly inventory of every Terragrunt output with Kestra. run-all output -json is parsed by Python and summarized into a Slack digest.

Categories
Infrastructure

Terraform outputs are the public interface of every unit, endpoints, connection strings, resource ids, yet most teams only see them one folder at a time, moments after an apply. This blueprint builds a living inventory of what every environment exposes: terragrunt run-all output -json captures the outputs of every unit in the estate into a single file, a Python task parses and counts them, and Slack receives a weekly digest listing every output name. The raw JSON stays attached to the execution as an artifact, so the digest is a headline and the artifact is the record.

The demo estate ships inline through inputFiles with two units whose modules expose two outputs each, and the task applies them first so outputs exist, no cloud credentials required.

How it works

  1. collect_outputs (io.kestra.plugin.terragrunt.cli.TerragruntCLI) materializes the repo, runs terragrunt run-all apply --non-interactive --working-dir live so the demo units have state, then captures terragrunt run-all output -json --working-dir live into inventory.json, exported through outputFiles.
  2. summarize_inventory (io.kestra.plugin.scripts.python.Script on the Process task runner) reads the file with a lenient raw_decode loop, because run-all output emits one JSON document per unit, and counts documents and output values.
  3. The counts and the sorted output names are emitted through Kestra's outputs protocol as {{ outputs.summarize_inventory.vars.* }}.
  4. post_digest posts the summary to Slack, and the errors block escalates a broken run to Discord, the digest is routine, a missing inventory is an incident.
  5. A disabled-by-default Schedule trigger refreshes the inventory every Monday at 07:00.

What you get

  • A weekly, timestamped answer to "what does our estate actually expose right now".
  • The raw per-unit output JSON preserved as an execution artifact for diffing and audits.
  • Unit and output counts as structured flow outputs, ready for thresholds, for example alerting when an expected output disappears.
  • A digest channel and an escalation channel kept deliberately separate.

Who it's for

  • Platform teams whose consumers keep asking for endpoints and ids that already exist as Terraform outputs.
  • Engineers auditing which units expose secrets-adjacent values that should move to a secret manager.
  • Teams building service catalogs who want the source of truth pulled from state, not from a wiki.

Why orchestrate this with Kestra

Collecting outputs by hand means running commands in N folders and pasting results into a document that is stale by Friday. Kestra runs the collection on a schedule, stores every snapshot as an execution artifact, turns the counts into structured outputs other flows can consume, and routes the result to the people who need it. The inventory becomes a pipeline product instead of a chore.

Prerequisites

  • A Slack incoming webhook for the digest and a Discord incoming webhook for failure escalation.
  • Python available on the Kestra host for the Process task runner, or swap it for the Docker task runner.
  • No cloud credentials are needed for the demo. For a real estate, drop the apply command, point the task at your repository and remote state, and pass provider credentials through the task env from {{ secret('...') }}.

Secrets

  • SLACK_WEBHOOK_URL: Slack incoming webhook URL.
  • DISCORD_WEBHOOK_URL: Discord incoming webhook URL.

Quick start

  1. Add the SLACK_WEBHOOK_URL and DISCORD_WEBHOOK_URL secrets to your Kestra namespace.
  2. Execute the flow and check the Slack digest reports 2 units and 4 output values.
  3. Point the flow at your real repository, remove the demo apply, and set disabled: false on the weekly trigger.

How to extend

  • Replace the inline inputFiles with namespaceFiles or a Git clone so the inventory reflects your real estate.
  • Diff each week's inventory.json against the previous execution's artifact and alert on removed outputs.
  • Write the parsed inventory to a database with a JDBC Query task to power dashboards or a service catalog.
  • Switch the underlying binary to OpenTofu with an image that ships tofu and the TERRAGRUNT_TFPATH environment variable in the task env.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.