tfplan

package
v0.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package tfplan reads the plans a `terragrunt run --all --json-out-dir <dir>` run leaves — one `terraform show -json` rendering per unit, under <dir>/<unit>/ — and renders the markdown summary a reviewer approves: the totals, every destroyed resource, a per-unit add/change/destroy table and each changed unit's resource list, destroys first.

Index

Constants

View Source
const (
	ActionCreate  = "create"
	ActionUpdate  = "update"
	ActionDelete  = "delete"
	ActionReplace = "replace"
	ActionImport  = "import"
)

Planned-change labels, as a reviewer reads them in the summary.

View Source
const JSONFile = "tfplan.json"

JSONFile is the name terragrunt gives each unit's `terraform show -json` rendering of its plan under --json-out-dir.

Variables

This section is empty.

Functions

func FailedSummary

func FailedSummary(title string, err error) string

FailedSummary is the summary a failed plan leaves in place of the unit tables, so a PR comment or job summary says why there is no plan.

func Summary

func Summary(title string, plans []UnitPlan) string

Summary renders the reviewer's markdown summary of the unit plans under title: the totals, every destroyed resource, a per-unit add/change/destroy table, and each changed unit's resource list. Units that destroy come first, then units with other changes, then unchanged units.

Types

type Change

type Change struct {
	// Address is the resource address (aws_s3_bucket.docs, module.x.aws_iam_role.y).
	Address string

	// Action is the change: create, update, delete, replace, import, or Terraform's
	// action list joined with "+" for any other combination (forget, …).
	Action string
}

Change is one planned change to a resource.

type UnitPlan

type UnitPlan struct {
	// Unit is the unit's path under the plan directory (e.g. "eks").
	Unit string

	// Changes lists the unit's planned resource changes, destroys first.
	Changes []Change

	// Add, Change, and Destroy count the resources the plan creates, updates, and
	// destroys, as Terraform's own "Plan:" line does (a replace is one add and one
	// destroy).
	Add, Change, Destroy int

	// Outputs reports whether the plan changes a root-module output value.
	Outputs bool
}

UnitPlan is one unit's planned changes, read from its JSONFile.

func ReadUnits

func ReadUnits(dir string) ([]UnitPlan, error)

ReadUnits reads every unit's JSONFile under dir, sorted by unit path. A missing dir reads as no units.

func (UnitPlan) HasChanges

func (p UnitPlan) HasChanges() bool

HasChanges reports whether applying the plan would change anything: a resource or an output.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL