Skip to content

feat: Stacks Terragrunt support - #3631

Merged
michaeljguarino merged 21 commits into
masterfrom
marcin/prod-4658-stacks-terragrunt-support
Jun 6, 2026
Merged

feat: Stacks Terragrunt support#3631
michaeljguarino merged 21 commits into
masterfrom
marcin/prod-4658-stacks-terragrunt-support

Conversation

@maciaszczykm

@maciaszczykm maciaszczykm commented May 29, 2026

Copy link
Copy Markdown
Member

Test Plan

Repository with samples: https://github.com/pluralsh/terragrunt-samples
Test environment: https://console.plrl-dev-aws.onplural.sh/
Test tag: pr-3631

Zrzut ekranu 2026-06-2 o 10 21 45 Zrzut ekranu 2026-06-2 o 10 21 25 Zrzut ekranu 2026-06-2 o 10 20 47

Checklist

  • I have added a meaningful title and summary to convey the impact of this PR to a user.
  • If required, I have updated the Plural documentation accordingly.
  • I have added tests to cover my changes.
  • I have deployed the agent to a test environment and verified that it works as expected (required only when changing agent code).

Plural Flow: console

@linear

linear Bot commented May 29, 2026

Copy link
Copy Markdown

PROD-4658

@maciaszczykm maciaszczykm added the enhancement New feature or request label May 29, 2026
@maciaszczykm
maciaszczykm marked this pull request as ready for review June 1, 2026 14:26
@greptile-apps

greptile-apps Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces end-to-end Terragrunt stack support across the console, deployment operator, and controller — adding the new TERRAGRUNT enum value, a dedicated TerragruntConfiguration type (parallelism, refresh, approveEmpty), a full Go Terragrunt tool implementation, a new harness Dockerfile, Elixir command generation, GraphQL schema changes, and frontend UI updates.

  • Go harness: New terragrunt package mirrors the Terraform tool (State, Plan, Output, HasChanges, Modifier, ConfigureStateBackend), wired into the tool.New dispatcher and Trivy scanner. The harness Dockerfile correctly verifies the SHA256 checksum of the Terragrunt binary before install.
  • Elixir backend: Adds terragrunt to the Stack.Type enum, an embedded Terragrunt configuration schema, and terragrunt_commands/2 that handles plan/apply/destroy flows (init is omitted intentionally — Terragrunt auto-initialises).
  • Frontend: New stackTypeUtils.ts centralises type labelling and isTerraformFamilyStackType; StackConfiguration.tsx reads/writes from the correct configuration block depending on stack type.

Confidence Score: 5/5

Safe to merge; changes are well-scoped, tested, and consistent with the existing Terraform tool patterns.

The implementation is thorough and consistent across all layers. The Go Terragrunt tool faithfully mirrors the Terraform tool, Elixir command generation is correct and covered by tests, the Dockerfile includes checksum verification, and the frontend properly reads from and writes to the correct configuration block. The only notable concern is that ConfigureStateBackend writes an _override.tf file which will be silently ignored for Terragrunt stacks sourcing remote Terraform modules — but this is a usage-pattern constraint rather than a correctness bug in the code itself, and the author has verified the feature against a real test environment.

go/deployment-operator/pkg/harness/tool/terragrunt/terragrunt.go — the _override.tf HTTP backend approach has a documented constraint worth keeping in mind for future Terragrunt module patterns.

Important Files Changed

Filename Overview
go/deployment-operator/pkg/harness/tool/terragrunt/terragrunt.go New Terragrunt tool implementation — mirrors the Terraform tool (State, Plan, Output, Modifier, ConfigureStateBackend, HasChanges). Uses _override.tf for HTTP state backend, which may not work for remote-source Terragrunt setups.
go/deployment-operator/pkg/harness/tool/terragrunt/modifier.go Adds PlanArgsModifier (injects -parallelism, -refresh, -out) and ApplyArgsModifier (appends plan file if not already present). Mirrors Terraform modifier exactly.
go/deployment-operator/pkg/harness/tool/terragrunt/terragrunt_templates.go Embeds and renders _override.tf.gotmpl to configure HTTP remote state backend. Output file is _override.tf, which only takes effect when Terraform .tf files reside alongside terragrunt.hcl.
go/deployment-operator/dockerfiles/harness/terragrunt.Dockerfile New multi-stage Dockerfile pulling Terraform, OpenTofu, and Terragrunt binaries. Downloads SHA256SUMS alongside the binary and verifies before installing.
lib/console/deployments/stacks/commands.ex Adds terragrunt_commands/2 (plan, destroy, apply variants). Missing init step is intentional — Terragrunt auto-runs init.
lib/console/schema/stack.ex Adds terragrunt to the Type enum (value 3) and embeds a Terragrunt configuration block. Changeset plumbing is correct.
assets/src/components/stacks/overview/StackConfiguration.tsx Reads toolConfig from the appropriate configuration block (terraform vs terragrunt) and sends the matching mutation key. Mutation dispatch logic is correct.
go/controller/api/v1alpha1/infrastructurestack_types.go Adds TERRAGRUNT to the StackType kubebuilder enum and TerragruntConfiguration type. Clean addition.
go/deployment-operator/pkg/harness/security/trivy/trivy.go Adds StackTypeTerragrunt to the Terraform scan case — correct since Terragrunt wraps Terraform HCL.
test/console/deployments/stacks/commands_test.exs Tests normal apply and destroy flows for Terragrunt. Missing coverage for the dry-run branch.

Reviews (2): Last reviewed commit: "add approvals, refresh and parallelism f..." | Re-trigger Greptile

Comment thread go/deployment-operator/pkg/harness/tool/terragrunt/terragrunt.go
Comment thread go/deployment-operator/dockerfiles/harness/terragrunt.Dockerfile
@maciaszczykm
maciaszczykm requested a review from a team June 1, 2026 14:53
@maciaszczykm

Copy link
Copy Markdown
Member Author

@greptileai

@michaeljguarino
michaeljguarino merged commit bbe0c59 into master Jun 6, 2026
166 of 195 checks passed
@michaeljguarino
michaeljguarino deleted the marcin/prod-4658-stacks-terragrunt-support branch June 6, 2026 00:44
@maciaszczykm maciaszczykm mentioned this pull request Jul 9, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants