feat(plan): estimate the full post-apply fleet from plan JSON (#51)#52
Merged
Conversation
estimate <plan.json> previously read only resource_changes and filtered no-op/delete actions, so a plan where most resources are unchanged returned a near-zero cost. Walk planned_values (the complete post-apply state) so every resource that will exist after apply is priced -- the same meaning as estimating the .tf, and consistent with infracost breakdown. Plans without planned_values fall back to resource_changes, keeping unchanged resources and excluding delete-only ones. Null child_modules entries no longer panic the walk. Behavior change: estimate <plan.json> (and --format json from a plan) now reports the full projected total, so --budget gates the whole fleet, not just the change. Resolves #51.
This was referenced Jul 18, 2026
Closed
andreacappelletti97
added a commit
that referenced
this pull request
Jul 18, 2026
estimate <plan.json> previously read only resource_changes and filtered no-op/delete actions, so a plan where most resources are unchanged returned a near-zero cost. Walk planned_values (the complete post-apply state) so every resource that will exist after apply is priced -- the same meaning as estimating the .tf. Plans without planned_values fall back to resource_changes, keeping unchanged resources and excluding delete-only ones. Null child_modules entries no longer panic the walk. Behavior change: estimate <plan.json> (and --format json from a plan) now reports the full projected total, so --budget gates the whole fleet, not just the change. Resolves #51.
Tyron2k
pushed a commit
to Tyron2k/c3x
that referenced
this pull request
Jul 21, 2026
…on safety Builds on c3xdev#52 (planned_values walk) with three additions: 1. PlanAction annotations: each resource from planned_values is annotated with its intent (create/update/no-op) from resource_changes via buildActionMap/classifyActions. This enables downstream delta rendering without losing completeness. 2. Deleted resources are appended with their pre-apply ("before") attributes and PlanActionDelete, so the delta renderer can show what is being removed and subtract its cost. 3. provider_config.expressions now uses json.RawMessage + parseExpression() instead of a strict struct. Terraform 4.x azurerm emits the features block as an array ([{}]) which crashed the previous decoder. Also adds PlanAction type and constants to domain.Resource.
Tyron2k
pushed a commit
to Tyron2k/c3x
that referenced
this pull request
Jul 22, 2026
…d view Deleted resources were appended to the output for the delta renderer but inadvertently inflated PROJECT TOTAL and appeared in the standard (non-delta) view — regressing the c3xdev#52 post-apply-fleet semantics. Fix: - NewEstimate skips PlanActionDelete costs when summing ProjectTotal. - Standard renderer skips deleted resources entirely (they only surface in --show-delta mode with the `-` marker). - Action markers (+/~/−) are now scoped to delta mode only; the normal estimate view shows no plan-action prefixes.
andreacappelletti97
pushed a commit
that referenced
this pull request
Jul 22, 2026
Adds a plan-aware delta view and resolves optional() type-constraint defaults, building on the full-fleet plan estimate from #52. - feat: c3x estimate --show-delta renders a diff-style view from plan JSON with +/~/- markers, a DELTA line (creates and updates net of deletions), and a rolled-up summary of unchanged resources. Falls back to the standard renderer with a stderr warning when there is no plan context (for example a plain .tf input). - feat: resolve optional(type, default) defaults from module variable type constraints for both the root and child modules, matching Terraform's runtime behavior so catalog expressions see real values instead of nil placeholders. - fix: guard the planned_values walk against a null child_modules element and the type-constraint walk against a zero-arg object(); both could panic the parser on untrusted plan or HCL input. - fix: exclude resources scheduled purely for deletion from PROJECT TOTAL so the estimate stays the post-apply fleet. Deletions surface only in the --show-delta view, where their cost is subtracted in the DELTA line. Co-authored-by: Tino Pittner <tino.pittner@rackspace.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the decision from #51.
Decision
c3x estimate <plan.json>now prices the full post-apply fleet (walkplanned_values), not just the resources the plan changes — the same meaning as estimating the.tf. This fixes the near-zero total for plans where most resources are unchanged.What changed
planned_values(the complete post-apply state); data sources and nullchild_modulesentries are skipped, not dereferenced.resource_changesfor older plan formats, now keeping no-op resources and excluding delete-only ones (post-apply semantics).--budgetgates the full projected total.Behavior change (called out for release notes)
estimate <plan.json>and--format jsonfrom a plan now report the full total.--budgettherefore gates the whole fleet. The change-only view remains available viac3x diff(and the upcoming--show-delta).Tests
New: unchanged-included, child-module walk with null-guard + data-source skip, fallback keeps-no-op/excludes-delete. Full suite +
go vetpass. Verified end-to-end: a plan with a no-op + a create now prices both.Thanks to @Tyron2k, whose #46 surfaced this; that PR can now rescope to the
--show-deltaview andoptional()defaults on top of this consistent base.Resolves #51.