Hi Infracost Team, When we run Infracost on the ma...
# help
f
Hi Infracost Team, When we run Infracost on the master branch, the price calculation for one of the resources is $0.0214656 USD. Two minutes later, running it again on the same branch generates a different cost of $0.02145 USD in the same region (cn-north-1). We are generating the cost in USD. Because of this, some projects in China always detect a change when running
infracost diff
, even if the files have not changed. This is only happening for
cn-north-1
resources.
w
AWS returns prices in CNY for China regions, so we have to convert them to USD, which is probably causing this issue. We’ve discussed this internally before and need to make a change to how we store and return the exchange rate in the JSON format. Until then one workaround you can do is to check the infracost.json file and if
diffTotalMonthlyCost
is less than $10 then skip posting a comment.
f
Why there is difference in runs that are 2 minutes apart we don’t understand? Is there is way to get the cost estimation in native currency without passing any parameter?
w
I think it might because the exchange rate is live and cached on our side so it’ll change but I haven’t dug into the code yet. For China, pass in
INFRACOST_CURRENCY=CNY infracost breakdown --path .
to get the native currency
l
Hi Ali. The problem we are running into, is that our stacks/project for China often also have resources in AWS Global. So we'll have a stack with
us-east-1
and
cn-north-1
resources, so it's not really feasible to set the currency to CNY just for China. Ideally, we do actually want to see the cost as USD, so what Infracost is attempting to do is good, but if the conversion rate changes frequently (like within a few mins), it creates too many changes in the cost analysis. Ideally, it would be great if the conversion rate could just be applied to the report, and not to determine if something now costs more or less. We have something like 300+ projects, and currently Infracost is generating too many false positives because the conversion rate changing makes the diff think that many untouched resources now have cost changes. We'd be happy to jump on a call sometime if that helps, but in the meantime just wanted to point that the current implementation makes the tool harder to use effectively in cross partition AWS setups.
If the currency could at least be guaranteed to stay the same from the time we run the breakdown, to the time we run the diff, that would already solve most of the issues.
w
@lively-telephone-89571 thanks for the feedback, can you possibly copy/paste ^ into a new issue in https://github.com/infracost/infracost/issues/new so we can track it and discuss implementation options there?
l
I'll write something up today.
Hopefully that captures the issue accurately
w
Thank you!