• Nijaguna Darshan

    Nijaguna Darshan

    7 months ago
    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?
        - '**.tf'
        - '**.tfvars'
        - '**.tfvars.json'
        runs-on: ubuntu-latest
        name: Show infracost diff
        - name: Check out repository
          uses: actions/checkout@v2
        - name: Run infracost diff
          uses: infracost/infracost-gh-action@master
            INFRACOST_API_KEY: ${{ secrets.INFRACOST_API_KEY }}
            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
            path: terraform
            usage_file: infracost-usage.yml
  • Alistair (Infracost)

    Alistair (Infracost)

    7 months ago
    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

    7 months ago
    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)

    7 months ago
    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.
    We should be publishing v1 to the actions marketplace this week.
  • Nijaguna Darshan

    Nijaguna Darshan

    7 months ago
    Wow! That's awesome. Well, beginners luck definitely seems to be on my side tho. 😀 I appreciate your prompt response @Tim (Infracost) 💯