Giter Club home page Giter Club logo

Comments (11)

alikhajeh1 avatar alikhajeh1 commented on May 18, 2024 1

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.

alikhajeh1 avatar alikhajeh1 commented on May 18, 2024 1

@sinabakh correct! Users might appreciate the heads-up and have a little more time to switch.

from infracost.

alikhajeh1 avatar alikhajeh1 commented on May 18, 2024

@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.

sinabakh avatar sinabakh commented on May 18, 2024

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.

aliscott avatar aliscott commented on May 18, 2024

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:

  1. Cost component doesn't change -> existingMonthlyCost == plannedMonthlyCost
  2. Existing cost component does change, e.g. instance type is changed.
  3. New cost component gets added to existing resource
  4. Cost component gets removed from existing resource
  5. New resource is added
  6. Resource gets removed
  7. If only the state is used (--use-tfstate)

from infracost.

sinabakh avatar sinabakh commented on May 18, 2024

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.

aliscott avatar aliscott commented on May 18, 2024

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.

alikhajeh1 avatar alikhajeh1 commented on May 18, 2024

@aliscott +1 on those names

from infracost.

sinabakh avatar sinabakh commented on May 18, 2024

It looks good to me, will start working on it.

from infracost.

alikhajeh1 avatar alikhajeh1 commented on May 18, 2024

@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.

sinabakh avatar sinabakh commented on May 18, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.