Hello guys! I have set up a github CI/CD using inf...
# general
d
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?
Copy code
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
l
Hi @dry-airplane-95831 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?
d
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?
c
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.
👍 1
We should be publishing v1 to the actions marketplace this week.
🙌 1
d
Wow! That's awesome. Well, beginners luck definitely seems to be on my side tho. 😀 I appreciate your prompt response @crooked-daybreak-55253 💯
c
FYI: I created a https://github.com/infracost/infracost/issues/1115, if you want to follow the progress.