Title
#general
Nijaguna Darshan

Nijaguna Darshan

11/08/2021, 3:43 PM
Hello guys! I have set up a github CI/CD using infracost for AWS cost estimation and I want to save the o/p as a json file. I understand that I have to define a job that does it.... but I'm not able to do it. Below is the infracost.yml file... can someone please help me out here?
3:44 PM
on:
  pull_request:
    paths:
    - '**.tf'
    - '**.tfvars'
    - '**.tfvars.json'
jobs:
  infracost:
    runs-on: ubuntu-latest
    name: Show infracost diff
    steps:
    - name: Check out repository
      uses: actions/checkout@v2
    - name: Run infracost diff
      uses: infracost/infracost-gh-action@master
      env:
        INFRACOST_API_KEY: ${{ secrets.INFRACOST_API_KEY }}
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        path: terraform
        usage_file: infracost-usage.yml
Alistair (Infracost)

Alistair (Infracost)

11/08/2021, 3:58 PM
Hi @Nijaguna Darshan just to understand are you wanting to run the action and then save the Infracost output JSON file somewhere? What is it you are wanting to do with that file?
Nijaguna Darshan

Nijaguna Darshan

11/08/2021, 4:26 PM
Yes, that is correct. I want to get the diff value as an input (json) to the OPA to allow/deny the changes in IaC. Please, lmk if there is a better way to do it?
Tim (Infracost)

Tim (Infracost)

11/08/2021, 4:38 PM
There’s not a great way to do this with the current github action BUT your timing is pretty good: We’ve been working on a new “setup-infracost” action which lets you use the full cli (similar to setup-terraform). Checkout this example for how it could be used.
4:39 PM
We should be publishing v1 to the actions marketplace this week.
Nijaguna Darshan

Nijaguna Darshan

11/08/2021, 4:43 PM
Wow! That's awesome. Well, beginners luck definitely seems to be on my side tho. 😀 I appreciate your prompt response @Tim (Infracost) 💯
Tim (Infracost)

Tim (Infracost)

11/08/2021, 4:48 PM
FYI: I created a https://github.com/infracost/infracost/issues/1115, if you want to follow the progress.