Comments (11)
Running infracost twice (on the master vs current branch, or before vs after the change) is one option. Another option is for infracost to use the output from the terraform plan
as the diff of the infrastructure about to be created, and show the cost for that, so infracost is run once. I haven't thought much about the implications of this yet, Atlantis's Checkout Strategy might be relevant to consider.
from infracost.
@sinabakh correct! Users might appreciate the heads-up and have a little more time to switch.
from infracost.
@m-yosefpor I'd ignore tfplan
as we'll probably remove that (a user pointed out that it's confusing and the json one or the tfdirs one can be used to achieve the same thing anyway). I'd also ignore tfstate
for now since that's not supported yet.
If it helps simplify the implementation, the main use-case for this is in CI systems or in a local dev machine, where both version a
and b
would be using the same tfjson
or tfdirs
flag since the user is comparing versions of the same thing (i.e. it should be rare to see --tfdir first/path --tfjson second/path
). Furthermore, enforcing that version a
and b
have to be the same "type" doesn't preclude us from supporting mixed formats in the future as we could relax that constraint.
from infracost.
I was thinking about working on it, but did not get a general idea and what is needed. Could you please elaborate more?
from infracost.
Notes from discussion
Update JSON output to have the following top level fields:
- existing_resources
- planned_resources
- resource_changes
All these keys have the same field structure as our existing resources
field.
Cases to think about:
- Cost component doesn't change -> existingMonthlyCost == plannedMonthlyCost
- Existing cost component does change, e.g. instance type is changed.
- New cost component gets added to existing resource
- Cost component gets removed from existing resource
- New resource is added
- Resource gets removed
- If only the state is used (--use-tfstate)
from infracost.
For starters, I will try to change the JSON output and then add the original functionality in a separate MR.
@aliscott Are we ok with these fields names? Or it needs more investigation?
from infracost.
As a reference:
Terraform uses:
prior_state (when it's a plan file) / values (when it's a state file)
planned_values
resource_changes
Pulumi uses:
oldState
newState
detailedDiff
Options:
Currently I'm thinking this hierarchy:
existingState:
resources:
...
totalHourlyCost
totalMonthlyCost
plannedState:
resources:
...
totalHourlyCost
totalMonthlyCost
diff:
resources:
...
totalHourlyCost
totalMonthlyCost
timeGenerated
resourceSummary
@sinabakh @alikhajeh1 any thoughts?
from infracost.
@aliscott +1 on those names
from infracost.
It looks good to me, will start working on it.
from infracost.
@sinabakh it would be good to have the current top-level JSON keys in the JSON file for the next release 0.7.17
, and ensure that infracost report
still continues to work (terragrunt users rely on that, I can help you test that if needed), then in 0.8.0
we'll remove the old keys and put in the usual "breaking change" release note.
from infracost.
@alikhajeh1 So if I understand correctly, we will first add new keys alongside the current ones and then will remove the current ones right? I just started working on this task, thanks for heads up.
from infracost.
Related Issues (20)
- Infracost v0.10.33 being Killed HOT 17
- Incorrect Comments in infracost-usage.yml Template for RDS Cluster Read/Write Metrics HOT 1
- Add `aws_codepipeline` support
- Support aws_appautoscaling_policy for ECS Service
- Allow specifying custom resources HOT 5
- Custom GitHub comment or add image
- Support Azure Repos active comment thread
- Infracost integration with GitHub Actions doesn't display cost estimation in PR comments HOT 1
- Cost Estimation Regression in Azure Terraform IAC: Prices Default to $0 from v0.10.32 Onwards HOT 4
- Add support for some SES and SESv2 resources HOT 1
- infracost is not fetching variables defined in Terraform Enterprise HOT 1
- Missing cost for ECS Service when task definition is used from a module and "family:revision" is used instead of "arn" or "family"
- Breakdown timing after 0.10.32+ HOT 1
- Error Generating Breakdown with v0.10.35 HOT 9
- `--debug-report` flag throws an error
- Missing cost estimate for `azurerm_postgresql_flexible_server` compute GP_Standard_D2ds_v5 HOT 3
- Will Infracost work or support OpenTofu? HOT 1
- Add support for `aws_servicecatalog_product`
- New `terraform test` support for variables in run block causes module evaluation to fail HOT 2
- Comment only when costs change
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from infracost.