Hello, Trying to test infracost to see how it work...
# help
e
Hello, Trying to test infracost to see how it works .. using the cli i can generate the cost estimate json using:
Copy code
infracost.exe breakdown --path ./terraform/ --terraform-var-file ./vars/uat.tfvars --format json --out-file infracost-base-uat2.json
infracost.exe upload --path infracost-base-uat2.json
But when I use the comment command i am getting an error (trying to get data on the dashboard)
Copy code
infracost.exe comment gitlab --repo /path/to/repo --merge-request 17 --path=infracost-base-uat2.json --gitlab-token xxxxxxxxx --gitlab-server-url <https://baseurl.com>
Estimate uploaded to organization 'xxx' in Infracost Cloud
Error: The pull request comment was generated successfully but could not be posted:
Error creating comment: 404 Not Found
Wondering if you have an idea why
w
Hi there! the 404 is coming from gitlab’s API so it’s probably related to the gitlab repo path, does the repo have a namespace in gitlab?
e
Yes, the repo is under two subgroups. The full url would be: https://baseurl.com/subgroup1/subgroup2/repo.git
w
Do you want to jump on a quick screenshare to debug? Are you trying with
--repo subgroup1/subgroup2/repo
? Running with
--log-level debug
might give clues too
e
that did the trick thanks! I was trying --repo /subgroup1/subgroup2/repo
w
Sweet! I’ll update https://www.infracost.io/docs/features/cli_commands/#gitlab and the
infracost comment gitlab --help
to clarify that
e
One last question regarding pricing. We are reviewing this and our case would be running all cost estimates within the cicd pipeline (so a technical service account) and then the accounting team of 10 people to review costs on the dashboard. Would that be 11 paid users? Or a user that worked on the repo is considered a user licence wise? (even if he is not the one interacting with infracost NOR going to the dashboard)
w
Engineers that worked on the repo would also be considered needing a license. For example, this command’ll show how many people committed terraform changes in a repo in the last 90 days - just to give you an idea of how many there are.
Copy code
git log --format='%aN <%aE>' --since=90.days -- \*.tf \*.tf.json \*.hcl \*.hcl.json \*.tfvars \*.tfvars.json \*/infracost.jml \*/infracost.yaml \*/infracost-usage.yml \*/infracost-usage.yaml | awk -F '<' '{ print $1 }' | sort | uniq
Saying that - @early-queen-42970 is chatting with users to get feedback on this and see what works for you
(even if he is not the one interacting with infracost NOR going to the dashboard)
this is interesting, so the engineers won’t see the merge request comment? as in, you’d use infracost for high-level visibility and guardrails mostly?
e
They will see anything on the repo (comments included) as they will work on infra changes. But cost management is not really their concern. There is a dedicated accounting team that will oversee costs of all projects. (we have hundreds of projects .. i would say 300 devs involved in infra provisionning)
but they would not go on the dashboard to see anything, they just work on the infra code
w
Makes sense - I just tagged @early-queen-42970 to jump in as he leads our pricing and we’ve had similar conversations with other enterprises
e
thank you 🙂 I will continue testing on my side Trying to get the results on the dashboard now
e
Hey - happy to talk through pricing
do you want to send me a quick email, we can jump on a call and discuss pricing: hassan.hosseini@infracost.io
But to answer your question - anyone who makes infrastructure changes would require a seat. It doesn't matter how many changed they make - they can do as many as they like. From the central dashboard then, you can see everything and setup the central guardrails, the policies, also you can enter your enterprise agreement discounts, reporting, etc. Happy to give an end to end demo to you and the team also!
e
Hello, Ok it's clear thanks. I will relay the info to the accounting team when we can present them a little of our test. Sorry, have to request some more help 😄 I cant get the data of my cost estimates to show on the dashboard. Tried the troubleshooting guide but didnt solve it. This is what I am doing:
Copy code
infracost.exe breakdown --path ./terraform/ --terraform-var-file ./vars/uat.tfvars --format json --out-file infracost-before-change.json
#make a terraform change
infracost.exe diff --path ./terraform/ --terraform-var-file ./vars/uat.tfvars --compare-to infracost-before-change.json --format json --out-file infracost-diff.json
infracost.exe comment gitlab --repo subgroup1/subgroup2/repo --merge-request 17 --path infracost-diff.json --gitlab-token xxxxxxxxxxx --gitlab-server-url <https://baseurl.com>
The diff is working fine by giving me an estimate of the changes, the comment appears correctly in gitlabs merge request, and the estimate shows as well in the repo tab. But nothing in dashboard and no pull request detected
w
Can you check if in Infracost Cloud > Org Settings > Cost estimate dashboard is enabled?
e
it is
w
ah because you’re running this on your machine (and not on gitlab CI), the required env vars (from gitlab) are not available to the CLI so you need to set them manually:
Copy code
export INFRACOST_VCS_PROVIDER=gitlab
export INFRACOST_VCS_REPOSITORY_URL=<https://gitlab.com/>...
export INFRACOST_VCS_PULL_REQUEST_URL=<https://gitlab.com/>...
export INFRACOST_VCS_PULL_REQUEST_AUTHOR="ali"
export INFRACOST_VCS_PULL_REQUEST_TITLE="test MR"

infracost.exe breakdown... (same commands as before)
e
ahhhhh thanks, i thought it would be picked up from the metadata in the json I should have followed the jenkins guide i guess: https://github.com/infracost/infracost-jenkins/
thank you
w
anytime 🙂 https://www.infracost.io/docs/features/environment_variables/#environment-variables-to-override-metadata is the page you want for those env vars, I also highly recommend setting the optional env vars as that way the people in your accounting team have the full context of the change, e.g. what was the base branch or the commit message.
e
will give it another try tomorrow to try and finalize the demo thanks. Hopefully wont bother you anymore 😄 have good day/night
w
To be clear, the env vars are used to set the metadata in the breakdown and the diff JSON, so those env vars need to be set before those commands are run on your local machine. But in GitLab CI, the CLI picks these up automatically so you shouldn’t need to do that.