- Home
- Skills
- DevOps & Cloud
- Terraform Plan Check
Works with the AI Agents you already use
Terraform Plan Check
A block removed from the configuration, or an item gone from a count list, deletes the object it managed.
$7
Terraform Plan Check
Example session with this skill installed
Here is the plan of this pull request (plan.json, from terraform show -json tfplan). Before I apply it: what does it destroy or replace, why, and what should I change?
- Read your context and instructions
- Compiled the terraform plan check
Sample result: a pull request's Terraform plan, read before apply (the demo plan)
Summary. VERDICT: FAIL 2 (7 REVIEW) (1 value not read): 6 resource changes, 11 rows: 2 FAIL, 7 REVIEW, 2 INFO, and 1 value not read. Applying this
plan replaces the orders database (Terraform deletes it first, then creates an empty one: storage_encrypted cannot
change in place) and deletes the old_logs bucket (its block was removed from the configuration). It also opens
port 22 to the whole internet, turns on force_destroy on a bucket and grants s3:*. The plan was made by
Terraform 1.17.2 with hashicorp/aws 6.74.0.
The result (terraform show -json tfplan > plan.json; python3 scripts/plancheck.py plan.json)
plancheck: plan.json: format_version 1.2, terraform_version 1.17.2, 6 resource changes
FAIL replace-data aws_db_instance.orders delete-then-create /resource_changes/0 data=yes reason=replace_because_cannot_update replace_paths=[storage_encrypted] sensitive=2 unknown=47
REVIEW aws-deletion-protection-off aws_db_instance.orders delete-then-create /resource_changes/0/change/after/deletion_protection null (the documented default: false) (unchanged)
INFO create aws_iam_policy.deploy create /resource_changes/1 data=no reason=- replace_paths=[] sensitive=0 unknown=6
REVIEW aws-iam-service-star aws_iam_policy.deploy create /resource_changes/1/change/after/policy Statement/0/Action/0 = "s3:*" (new)
REVIEW update-data aws_s3_bucket.assets update /resource_changes/2 data=yes reason=- replace_paths=[] sensitive=0 unknown=0
REVIEW bucket-force-destroy aws_s3_bucket.assets update /resource_changes/2/change/after/force_destroy true (new)
FAIL delete-data aws_s3_bucket.old_logs delete /resource_changes/3 data=yes reason=delete_because_no_resource_config replace_paths=[] sensitive=0 unknown=0
INFO update aws_security_group.web update /resource_changes/4 data=no reason=- replace_paths=[] sensitive=0 unknown=0
REVIEW aws-sg-ingress-world aws_security_group.web update /resource_changes/4/change/after/ingress/0/cidr_blocks/0 "0.0.0.0/0" (new)
REVIEW aws-sg-ingress-world aws_security_group.web update /resource_changes/4/change/after/ingress/1/cidr_blocks/0 "0.0.0.0/0" (unchanged)
REVIEW moved aws_sqs_queue.order_jobs no-op /resource_changes/5/previous_address from aws_sqs_queue.jobs
changes: 1 create, 2 update, 1 delete, 1 delete-then-create, 1 no-op
rows: 2 FAIL, 7 REVIEW, 2 INFO, 0 NOT READ
drift: 0
values not read: 1
aws-iam-action-star, aws-iam-service-star /resource_changes/2/change/after/policy: null: the provider decides it, and the plan does not say how: the rule could not judge it
not read: 0
VERDICT: FAIL 2 (7 REVIEW) (1 value not read)
What to change before apply
- FAIL
aws_db_instance.orders, delete-then-create because ofreplace_paths=[storage_encrypted]: the RDS instance's
data goes with it. Do not flip encryption on a live instance; encrypt a snapshot copy, restore from it and switch over,
or keepstorage_encryptedas it is for now (the fixed plan below does that). - FAIL
aws_s3_bucket.old_logs, delete (delete_because_no_resource_config): if the logs are still wanted, put the
block back, or take the bucket out of the state with aremovedblock (destroy = false) so the bucket is kept. - REVIEW port 22 open to
0.0.0.0/0(ingress/0, new): restrict it to a known range or use SSM; port 443 was open before. - REVIEW
force_destroy = trueonaws_s3_bucket.assets: a later destroy then empties a bucket that has objects.
Leave it off unless the bucket is disposable. - REVIEW
s3:*inaws_iam_policy.deploywithResource = "*": name the actions and the buckets the deploy needs. - REVIEW
deletion_protectionof the newordersdatabase is null, which the AWS provider documents as false:
nothing stops a later delete of it. Setdeletion_protection = truein the configuration. - Value not read:
policyofaws_s3_bucket.assetsis null (the plan does not say whether the bucket holds a
policy set elsewhere): the star-action rules could not judge it, so the verdict says so. Check the bucket's policy by hand. - REVIEW moved
aws_sqs_queue.jobstoaws_sqs_queue.order_jobs: a rename in the state only; check the address is the one meant.
The fixed plan (plan-ok.json: encryption left alone, the old bucket kept, port 22 and s3:* gone)
plancheck: plan-ok.json: format_version 1.2, terraform_version 1.17.2, 6 resource changes
REVIEW update-data aws_db_instance.orders update /resource_changes/0 data=yes reason=- replace_paths=[] sensitive=2 unknown=0
REVIEW aws-encryption-off aws_db_instance.orders update /resource_changes/0/change/after/storage_encrypted false (unchanged)
REVIEW aws-deletion-protection-off aws_db_instance.orders update /resource_changes/0/change/after/deletion_protection false (unchanged)
INFO create aws_iam_policy.deploy create /resource_changes/1 data=no reason=- replace_paths=[] sensitive=0 unknown=6
REVIEW moved aws_sqs_queue.order_jobs no-op /resource_changes/5/previous_address from aws_sqs_queue.jobs
changes: 1 create, 1 update, 1 no-op, 3 plain no-op
rows: 0 FAIL, 4 REVIEW, 1 INFO, 0 NOT READ
drift: 0
values not read: 0
not read: 0
VERDICT: PASS (4 REVIEW)
Next steps
- Make the FAIL rows go away or decide them out loud: a replace of a database needs a migration plan, not an apply.
- Read every REVIEW row: PASS means no FAIL row, not that nothing needs reading.
- In CI, run
terraform show -json tfplan > plan.jsonandpython3 scripts/plancheck.py plan.json --json --out plan-review.json,
and stop the apply on exit 1 (a FAIL, INCOMPLETE or NOTHING REVIEWED). - The rows come from the plan alone: what a provider does at apply time beyond what the plan says is not seen.
Connects securely to your tools. The creator never sees your data.
About this skill
The problem
terraform plan ends with a count such as 1 to add, 0 to change, 1 to destroy. Behind it can be a database deleted and created again, empty, because one attribute (storage_encrypted, a name, an engine) cannot change in place; the line that says so is one of hundreds in the plan's text. A block removed from the configuration, or an item gone from a count list, deletes the object it managed. And a reviewer, human or agent, that skips the part of a plan it cannot read often does so without a word.
What it does
Your agent runs one standard-library Python script over the plan's JSON (terraform show -json tfplan, from Terraform 0.12 onward or OpenTofu, or the redacted plan JSON that HCP Terraform's API serves for a run) and explains the result. One row per resource change (each count and for_each instance, each module's resources and each deposed object is its own change): the address, the plan's own action, its action_reason (cannot update, tainted, -replace, replace_triggered_by, the block removed, a count index or for_each key gone), the replace_paths that force a replacement, whether the type holds data, and how many values are sensitive or unknown until apply. Each row has a class:
- FAIL: a delete or replace of a type that holds data: databases, caches, buckets, volumes and disks, file systems, keys, DNS zones, secrets, queues, registries, log groups, and what deletes its contents with it (a resource group, a project, a CloudFormation stack). A type the built-in table does not name counts as holding data. With
--strict, every delete or replace is FAIL. - REVIEW: a delete or replace of a type that holds no data, an update in place of one that does, a forget, a move, and the value rules on the after-values: ingress open to
0.0.0.0/0or::/0(AWS security groups and their rules,google_compute_firewall, Azure NSGs and their rules),"*"and service-wide (s3:*) IAM actions, Azure role actions*, the Google basic roles roles/owner and roles/editor, encryption, deletion protection, purge protection or HTTPS-only turned off,force_destroyandskip_final_snapshot, each on the types its row of the rule table names. - INFO: a create, an update in place of a type that holds no data, a data source read, an import.
Drift (resource_drift: what changed outside Terraform since the last apply) is listed apart, not in the verdict. Each value a rule reads, and each key that says whether a rule applies (an SG rule's type, an Azure rule's direction and access, a Google firewall's allow, a policy statement's Effect), that is left out, null with no default cited in the rule table, unknown until apply, sensitive (in clear or redacted), of another type, or a policy that is not JSON, and each part of the plan it does not review (deferred changes, action invocations, a key it does not know), is listed with its JSON pointer. The verdict is PASS (exit 0) only when every change was read and nothing is listed as not read; otherwise FAIL n, INCOMPLETE n of m (anything not read, or a plan that says it errored or is not complete) or NOTHING REVIEWED (an empty file, a state file, a binary plan file, text, a plan with no change to read), each exit 1; a usage error exits 2. It reads the one file you name, opens no socket, calls no provider and writes only the --out file you give.
How often it says PASS
How often it says PASS, measured: of the 96 real files of this check, 45 (47%) PASS, 6 FAIL, 22 are INCOMPLETE and 23 NOTHING REVIEWED (state files and plans with no change among them); of the 42 first applies (plans that only create), 26 PASS and 16 are INCOMPLETE, and of the 24 first applies in the AWS test plans of checkov and infracost, 9 PASS. On the current hashicorp/aws provider (6.x) a first apply is INCOMPLETE whenever it creates an aws_s3_bucket, aws_iam_role, aws_sqs_queue, aws_sns_topic, aws_kms_key, aws_secretsmanager_secret, aws_vpc_endpoint, aws_api_gateway_rest_api, aws_s3_access_point or aws_opensearch_domain whose policy is not written in its own block (the provider decides policy, inline_policy or access_policies at apply even when none is wanted), and whenever it creates an aws_instance (its ebs_block_device comes from the AMI at apply, even with root_block_device set). Setting a value does not clear these: read the separate policy resource's row (aws_s3_bucket_policy, aws_sqs_queue_policy and the others are read) and the AMI's block device mappings, and count those values as read by hand. Of 4 first applies planned with Terraform 1.17.2 and the current AWS provider (a bucket; twelve ordinary resources; an EC2 instance with its security group; the terraform-aws-modules VPC module), none PASS, and of 106 first applies in terraform-compliance's test plans (mostly Terraform 0.12), 43 (41%) PASS and 25 of its 87 AWS ones. A first plan is INCOMPLETE when a value a rule reads is decided at apply (an instance's ebs_block_device, an unset policy, a policy that names a resource not made yet) or a setting a rule needs (encryption, deletion protection) is left out, or is null and references/rules.md cites no default for it: that setting you can set in the configuration; what is decided at apply you read by hand. A VM replace is REVIEW, not FAIL: its row names the disks that go with it.
What you get that prompt-only skills don't
- The rules are a table, not memory. The same plan gives the same rows every time; the 33 rules are data the check tests one by one, each with an example that fires it and a near miss that fires another.
- What was not read is counted and named, with its JSON pointer, and a run that read nothing says NOTHING REVIEWED: a missing row is not presented as proof that nothing is lost.
- Read on real plans, not only on a demo: 96 real plan files of five origins, compared row by row with two other engines (below).
- A CI exit code that stops an apply losing data, and a JSON form of every row.
Next to the Terraform plan skills already listed
Their own listing words, and what this one does about each (no package of theirs was downloaded: what their files do beyond their pages was not seen):
- terraform-plan-review ($5) already lists what is destroyed and what is replaced "(and which change forces it)", with a holds-data label from "a built-in list of types" for AWS, Google Cloud and Azure, an exit 1 for CI and JSON, and flags more kinds of setting than this one (ports one by one, public ACLs, public databases). Its page says other types are "listed but not judged"; here a type the table does not name counts as holding data, so its delete is FAIL. Each row here also carries the plan's own action reason, and drift is listed apart.
- terraform-replacement-destruction-review-card ($7) reads "format_version 1.x" plans up to a "maximum 20 MiB and 5,000 resource changes". Here format 0.1 plans of Terraform 0.12 are read as well, and a plan of 26,000 changes (69 MB) took 1.95 s and 386 MB of memory here.
- terraform-plan-blast-radius-safe-state-surgery ($9) says "Works with Terraform 1.1+ plan JSON and OpenTofu" and writes moved blocks, which this one does not. Here plans written by Terraform 0.12.31, 1.0.11, 1.14.0 and 1.17.2 and OpenTofu 1.6.3 and 1.13.10 were read, and a move already in the plan is its own row.
- terraform-plan-blast-radius-review ($12) says "A text-only plan is less precise than JSON." Here a text plan is not read at all: it says NOTHING REVIEWED and exits 1, so a CI step fed the wrong file stops.
- aws-terraform-plan-auditor ($9) reviews "cost-sensitive changes" on AWS. This one says nothing about cost, and reads Google and Azure types as well.
- terraform-reviewer-security-cost-drift-before-you-apply (free) adds "cost estimates" and reviews modules too. This one reads the plan only and gives no cost.
- terraform-safety-check ($5) is a "Static check of HCL text" before any plan. This one reads the plan, where
count,for_eachand module inputs are already evaluated, and needs one.
Why pay $7 when terraform show or checkov is free
terraform showandterraform planare the authority, and free: every change is in their text, with "forces replacement" beside the attribute. This adds one row per change that a CI step and an agent read alike, the holds-data label, the plan's action reason on each row, drift apart, and an exit code that stops an apply that loses data. If you read every plan's text in full yourself, you may not need it.- checkov is free and has far more policies (ports one by one, public ACLs, logging, tags), and it fails a provider default left unset; here a setting left unset makes the verdict INCOMPLETE, not FAIL, unless the rule table cites the provider's documented default for it (a
force_destroyorskip_final_snapshotnull is false: no row). For a compliance scan, use it. Its checks are about the configuration the plan arrives at, not about what the plan destroys or replaces. - tf-summarize is free too and lists what each plan creates, updates, replaces and deletes; it needs installing, and on these plans it had no entry for data source reads, forgets or drift (below).
- What you pay for here, each proved by the check: nothing to install (one file, Python's standard library, run alone in an empty folder); the holds-data table read type by type; the lists of what was not read, with the place; a verdict that is PASS only when every change and every value a rule reads was read; and every row explained by your agent with what to change.
How it works
- The agent gets the plan as JSON (
terraform plan -out=tfplan, thenterraform show -json tfplan > plan.json) and runs the script on it. - It reads the verdict and its ending, each FAIL and REVIEW row, the drift and the lists of what was not read.
- For each FAIL row it says in plain words what would be lost, why Terraform wants it (the reason and the attribute), and what to change; it does not edit the configuration to make the verdict pass.
What was checked, and how
Every number here is read from the check's own output (check.out) when this page is written.
- 504 regression cases (paths and exit codes, BOM, UTF-16, CRLF,
\uescapes, key order, files that are not a plan, format versions, the read-nothing gate, every action, holds-data, moved, import, forget, deposed, drift, the value rules,--strict,--json), each shown failing on at least one of 279 deliberately broken copies of the script, the rule table or SKILL.md. - The holds-data table, type by type: every resource type of hashicorp/aws 6.74.0, google 8.12.0 and azurerm 5.15.0 (4,308 types; 246 hold data, 1,450 do not, the rest are unknown and count as holding data) gets the answer the check records.
- Real plans of five origins, kept or reduced with their sources (inputs/SOURCES.md): OpenTofu's own
show -jsontest outputs, infracost's and checkov's test plans, one configuration planned by six Terraform and OpenTofu releases from 0.12 to 1.17, and offline Google and Azure plans. Some of the files are state outputs or plans with nothing to change, there to be refused:
| origin | files | with a change read | FAIL | REVIEW | INFO | NOT READ | drift | values not read | parts not read |
|---|---|---|---|---|---|---|---|---|---|
| OpenTofu test outputs | 34 | 25 | 3 | 10 | 58 | 0 | 3 | 0 | 7 |
| infracost test plans | 12 | 10 | 0 | 16 | 64 | 0 | 4 | 37 | 1 |
| checkov test plans | 24 | 23 | 1 | 28 | 127 | 1 | 0 | 40 | 2 |
| six engines, one configuration | 24 | 12 | 0 | 239 | 77 | 0 | 8 | 0 | 6 |
| Google and Azure, offline | 2 | 2 | 6 | 12 | 11 | 0 | 0 | 0 | 0 |
- Ground truth against two other engines: 790 rows (688 from 75 of the 96 real files, the rest from the demo and the examples of every rule) compared with tf-summarize 0.3.20 (what each change does) and checkov 3.4.11 (open ingress, star actions, protection off): 649 agree; each of the others is named: a change only one engine reports (104 only here, 32 only there), a class set differently (5), the other engine's gap or error (no entry for data source reads, forgets, no-ops or drift, a UTF-16 file it cannot parse, no check for a service-wide action), or a policy of this one, each stated under Known limitations.
- On those files, 50 faithful re-encodings (indented, compact,
\uescapes, BOM, CRLF, UTF-16, keys reversed) changed no result; every unordered list reversed moved no fact; all 761 JSON pointers of the rows resolve in their plan and hold what the row shows; 14 one-fact changes each changed a row as named, and 15 planted changes each came out as their own row, once; of the 317 changes the engines' own text plans name, 0 have no row of that address and action; of 50 rows read by hand, 49 were right, 0 wrong and 1 debatable. - The largest real plan (26 changes) takes 0.05 s; the same plan repeated to 26,000 changes (69 MB) takes 1.95 s and 386 MB of memory on the machine of this check.
Known limitations
- The plan alone: what a provider does at apply time beyond what the plan says, and what outside the plan depends on these resources, is not seen. A missing row is not proof that nothing is lost.
- A value a rule reads, or a key that says whether a rule applies, that is left out, or null with no provider default cited in the rule table, makes the verdict INCOMPLETE, not PASS; checkov fails a provider default left unset. A null whose default the rule table cites, from the provider's docs, is read as that default:
force_destroyandskip_final_snapshotnull are false (no row), an RDS database'sdeletion_protectionnull is false (a REVIEW row that says so), a Google firewall'sdirectionnull is INGRESS. A null source range is no source. - A value unknown until apply, sensitive (held in clear, or redacted as in HCP Terraform's redacted plan) or of another type, where a rule reads it is listed under values not read: that rule did not judge that resource, and the verdict is INCOMPLETE, exit 1.
- The value rules read creates, updates and replaces; a resource the plan leaves as it is, or deletes, has no value row (checkov checks those too). Values are compared trimmed and in any letter case.
- An output change is an INFO row and no value of it is read; a
checksresult is a row (a failed or errored one REVIEW). - The Google basic-role rule names roles/owner and roles/editor only; roles/viewer and custom roles give no row (checkov fails roles/viewer too).
- Not checked: ports one by one (SSH or database ports), public bucket ACLs, publicly accessible databases, cost.
- A VM or
local_fileis a type that holds no data by the table, though a VM's root disk can: a VM's delete or replace is REVIEW, not FAIL, and its row names the disks that go with it. aws_rds_cluster_instancecounts as holding no data (its data is in itsaws_rds_cluster): its delete or replace is REVIEW.- A setting with a documented default (
references/rules.mdcites each) that the plan shows as null is read as that default even where the plan marks it unknown until apply or sensitive, and the verdict can then be PASS: whereafter_unknownorafter_sensitivemarks such a setting, read it by hand. - Where a rule expects a list (
cidr_blocks, an Azure role definition'sactions) and the plan holds a single string, the string is read as one value; an empty or blank string there is not reported as a value not read. - Terraform 0.12 plans carry no sensitive marks and no drift: there the counts say nothing.
- A map key in
replace_pathsis shown like an attribute. - A change whose before or after is not of the type the format says (an
afterof null on a create, a list where an object belongs) is NOT READ: no rule judges it, and the verdict is INCOMPLETE. - JSON only: the text of
terraform plan, a CI wrapper's printout or the binary plan file is NOTHING REVIEWED. - Of the 50 rows read by hand, the one debatable is a VM create marked as holding no data (the limit above).
It reads the plan alone: what a provider does at apply time, and what outside the plan depends on these resources, is not seen, and a missing row is not proof that nothing is lost. A value a rule reads, or a key that says whether a rule applies, that is left out, null with no provider default cited in the rule table, unknown until apply, sensitive (in clear or redacted) or of another type makes the verdict INCOMPLETE; value rules read creates, updates and replaces (not deletes or resources left as they are), no value of an output change is read, and the Google basic-role rule names roles/owner and roles/editor only. Not checked: single ports, public ACLs, public databases, cost. A VM is a type that holds no data by the table: its delete or replace is REVIEW, not FAIL. aws_rds_cluster_instance counts as holding no data (its data is in its aws_rds_cluster): its delete or replace is REVIEW. A setting with a documented default (references/rules.md cites each) that the plan shows as null is read as that default even where the plan marks it unknown until apply or sensitive, and the verdict can then be PASS: where after_unknown or after_sensitive marks such a setting, read it by hand. Where a rule expects a list (cidr_blocks, an Azure role definition's actions) and the plan holds a single string, the string is read as one value; an empty or blank string there is not reported as a value not read. Each count and for_each instance and each resource in a module is judged from its own resource change: the plan's configuration (module sources and versions, the count and for_each expressions) is not read, so a shifted count index shows only as the changes the plan lists for each item, not as one shift. JSON only: a text plan or a binary plan file is NOTHING REVIEWED. A change nested more than a hundred levels deep is NOT READ (the real plans tried here nest seven deep at most); a file nested past what Python's JSON reader takes is NOTHING REVIEWED.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed today
- Software
Python
No accounts, API keys, database connection or services. Python 3.9+ on the machine.
Permissions
File Scopes
What's inside
Frequently Asked Questions
New in DevOps & Cloud
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for DevOps & Cloud.