Skip to content
DashboardWebsite

Terraform Plan Pack

URL slug: terraform-plan

The pack reads the text output of terraform plan and turns each resource change into its own analysis unit. The input can be one stack, or a Terramate run that prints several stacks one after the other. This page is for engineers who send plans to OpenTremor and want to know what each unit holds.

parse_plan (opentremor_pack_terraform_plan/parser.py) works in two steps:

  1. It finds every resource header and its stack. A header is a comment line # <address> <action wording> whose wording is one of Terraform’s action phrases (table below). The same pass reads terramate: Entering stack in <path> lines, so each header knows its stack (group_path).
  2. It cuts the body of each unit. A body runs from its header line to the next header. A Plan: N to add... summary line ends it earlier, because that line closes the stack’s section. A header with an empty body gives no unit.

One table answers both “is this line a header?” and “which action is it?”. The two answers cannot drift apart.

Phrase in the headeraction
will be createdcreate
will be destroyeddestroy
will be updated in-placeupdate
will be replaced / must be replacedreplace
is tainted, so must be replacedreplace
will be read during applyread
has moved to <address>move

type and name come from the address in the header, not from the resource body. The parser takes the last <type>.<name> of the address, after any module.<name> prefix and data.. Data sources and resources inside modules need no special handling:

Addresstypename
aws_security_group.webaws_security_groupweb
module.network.aws_subnet.privateaws_subnetprivate
data.aws_ami.latestaws_amilatest
module.buckets["logs.eu"].aws_s3_bucket.thisaws_s3_bucketthis
aws_iam_user.users["ops.team"]aws_iam_userusers["ops.team"]

In a multi-stack Terramate output, each header gets the stack of the last terramate: Entering stack in <path> line above it. That path is its group_path.

terramate: Entering stack in /infra/network/staging/eu-west-1
terramate: Executing command "terraform show -no-color tfplan"
Terraform will perform the following actions:
# aws_iam_role.ci_deploy must be replaced
...
Plan: 1 to add, 0 to change, 1 to destroy.
terramate: Entering stack in /infra/network/prod/global
...
# aws_iam_user.service_account will be created
...
Plan: 2 to add, 0 to change, 0 to destroy.
terramate: Entering stack in /infra/tooling/staging/eu-west-1
...
No changes. Your infrastructure matches the configuration.

This output gives one unit per header shown: one from the first stack and one from the second. The third stack has no changes, so it gives no unit.

{
"hash": "<sha256 of the normalised body>",
"type": "aws_security_group",
"name": "web",
"action": "update",
"body": " # aws_security_group.web will be updated in-place\n ~ resource ...",
"metadata": {
"generated_at_utc": "2026-04-28T10:30:00Z",
"source_path": null,
"group_path": "/infra/network/dev/eu-west-1"
}
}

group_path is null for plain terraform plan output, without Terramate.

The hash comes from OpenTremor Core’s libs/hash.py. Before hashing, core trims each line, drops blank lines, and drops every line that holds one of Terraform’s placeholders (case-insensitive):

Line dropped when it containsExample
(known after apply)id = (known after apply)
(sensitive value)password = (sensitive value)
(will be computed)arn = (will be computed)

So a second run of the same plan gets the same hashes, and OpenTremor reuses the earlier analysis instead of calling the LLM again. Two identical resource bodies in different stacks also share one stored analysis. This is on purpose: the stack path is not part of the body.

The rules are Markdown files in the package’s opentremor_pack_terraform_plan/rules/ folder:

FileServed at
generic-rules.mdGET /v1/terraform-plan/rules
aws-rules.mdGET /v1/terraform-plan/rules?rule_type=aws

To add a variant, add a {type}-rules.md file. The pack finds it on its own; there is nothing to register.

When most resources in a repository’s plan come from the AWS provider (aws_*, including resources in modules and data sources), the pack suggests the aws variant for that repository. The suggestion appears on the repository’s page in the dashboard. A person applies or dismisses it; the pack never changes the rules on its own. A plan split evenly between two providers gets no suggestion. Neither does a plan whose main provider has no rules here, such as Google or Azure. See OpenTremor-core#0024.

Core’s Markdown and HTML reports show group_path when it is set:

  • Resources are grouped by stack, and each resource section shows a Stack: /infra/... line.
  • The findings summary table gets a Stack column when at least one resource has a path. Single-stack plans have no such column.
Terraform will perform the following actions:
# aws_db_instance.orders will be created
+ resource "aws_db_instance" "orders" {
+ identifier = "orders-primary"
+ storage_encrypted = false
}
Plan: 1 to add, 0 to change, 0 to destroy.

This gives one unit with group_path: null:

{
"hash": "d4e8b1...",
"type": "aws_db_instance",
"name": "orders",
"action": "create",
"body": "...",
"metadata": { "generated_at_utc": "...", "source_path": null, "group_path": null }
}
Terminal window
terramate run terraform show -no-color tfplan > full_plan.txt

Send full_plan.txt as it is; it needs no preprocessing. You get one unit per changed resource across all stacks, each with its stack path.