GithubHelp home page GithubHelp logo

infracost / infracost-gh-action Goto Github PK

View Code? Open in Web Editor NEW
120.0 120.0 12.0 922 KB

GitHub Action for Infracost. Shows cloud cost estimates for Terraform in pull requests.

Home Page: https://infracost.io

License: Apache License 2.0

aws azure cost-estimation gcp github-actions infrastructure-as-code terraform terraform-cost-estimates

infracost-gh-action's Introduction

Infracost breakdown command

Infracost shows cloud cost estimates and FinOps best practices for Terraform. It lets engineers see a cost breakdown and understand costs before making changes, either in the terminal, VS Code or pull requests.

Docs Docker pulls Community Slack channel tweet

Get started

Follow our quick start guide to get started ๐Ÿš€

Infracost also has many CI/CD integrations so you can easily post cost estimates in pull requests. This provides your team with a safety net as people can discuss costs as part of the workflow.

Post cost estimates in pull requests

Infracost in GitHub Actions

Output of infracost breakdown

Infracost breakdown command

infracost diff shows diff of monthly costs between current and planned state

Infracost diff command

Infracost Cloud

Infracost Cloud is our SaaS product that builds on top of Infracost open source and works with CI/CD integrations. It enables you to check for best practices such as using latest generation instance types or block storage, e.g. consider switching AWS gp2 volumes to gp3 as they are more performant and cheaper. Team leads, managers and FinOps practitioners can also setup tagging policies and guardrails to help guide the team.

Infracost Cloud

Supported clouds and resources

Infracost supports over 1,100 Terraform resources across AWS, Azure and Google. Other IaC tools, such as Pulumi, AWS CloudFormation/CDK and Azure ARM/Bicep are on our roadmap.

Infracost can also estimate usage-based resources such as AWS S3 or Lambda!

Community and contributing

Join our community Slack channel to learn more about cost estimation, Infracost, and to connect with other users and contributors. Checkout the pinned issues for our next community call or our YouTube for previous calls.

We โค๏ธ contributions big or small. For development details, see the contributing guide. For major changes, including CLI interface changes, please open an issue first to discuss what you would like to change.

Thanks to all the people who have contributed, including bug reports, code, feedback and suggestions!

License

Apache License 2.0

infracost-gh-action's People

Contributors

alikhajeh1 avatar aliscott avatar hassankhosseini avatar m-yosefpor avatar tim775 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

infracost-gh-action's Issues

Disable auto comment in PR

Hello, devs. Could you please tell me how to disable auto comments in pull requests in GHA, but I still want outputs.

I tried the post_condition options with no results.

Add Terraform init custom flags

Hello, I'm trying to set up this awesome Action but I have a problem... My current tf configuration needs some custom flags to the terraform init path, and I'm seeing that the action only supports terraform_plan_flags. Would it be possible to add this configuration customizable too?

Thank you!!

path or config file are required so major version bump is required according to semver

path or config life are required.

that means is a breaking change and that means you should do a major version bump

this is my yaml:


name: Infracost

on: pull_request

jobs:
  infracost:
    runs-on: ubuntu-latest
    env:
      AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
      AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
    name: Show infracost diff
    steps:
      - name: Check out repository
        uses: actions/checkout@v2
      - name: HashiCorp - Setup Terraform
        uses: hashicorp/[email protected]
        with:
          terraform_version: 0.14.6
      - name: terraform fmt recursive check
        run: terraform fmt -recursive -check
      - name: terraform init
        run: terraform init
      - name: terraform plan
        run: terraform plan --out plan-file
      - name: Run infracost diff
        uses: infracost/[email protected]
        env:
          INFRACOST_API_KEY: ${{ secrets.INFRACOST_API_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          entrypoint: /scripts/ci/diff.sh
          usage_file: infracost-usage.yml
        # drop the following line
        continue-on-error: true

changing to infracost/[email protected] breaks the CI.

so ideally you should drop 0.6.0 release and bump to 1.0.0

Division by 0

steps to reproduce:

  1. create an empty terraform project
  2. add infracost-gh-actions on github actions
  3. before cost is 0 and after cost is 0. 0/0% = NAN%

Tomorrow I will create an empty repository with the reproducer.

Logs:

 $ infracost --no-color --usage-file infracost-usage.yml
time="2021-01-27T17:12:46Z" level=info msg="starting: Running terraform init"
time="2021-01-27T17:12:46Z" level=info msg="Running command: /usr/bin/terraform init -input=false -no-color"
time="2021-01-27T17:12:52Z" level=info msg="starting: Running terraform plan"
time="2021-01-27T17:12:52Z" level=info msg="Running command: /usr/bin/terraform plan -input=false -lock=false -no-color -out=/tmp/tfplan546450212"
time="2021-01-27T17:12:53Z" level=info msg="starting: Running terraform show"
time="2021-01-27T17:12:53Z" level=info msg="Running command: /usr/bin/terraform show -no-color -json /tmp/tfplan546450212"
time="2021-01-27T17:12:54Z" level=info msg="starting: Calculating cost estimate"
bc: divide by zero

[Feature Request] Allow to comment the commit even if the change is 0%

Sometimes you add resources that don't change the infrastructure cost. But you want a feedback or reminder of the total cost with no diff.

Description:
I as a GitHub action I want to comment on a PR when the infrastructure cost has not changed.

example of yaml:

      - name: Run infracost diff
        uses: infracost/[email protected]
        env:
          INFRACOST_API_KEY: ${{ secrets.INFRACOST_API_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          path: .
          entrypoint: /scripts/ci/diff.sh
          usage_file: infracost-usage.yml
          always_comment: true

Expected behavior:

  • A comment is posted on a PR/commit even if the cost is 0% and diff is equal.

Actual behavior:

   Running infracost output using:
  $ infracost output --no-color --format diff --path infracost_breakdown.json
Comment not posted as diff (0%) is less than or equal to percentage threshold (0%).

Posible alternative implementation:

  • Dont use <= is less than or equal to percentage threshold
  • instead use < is less than to percentage threshold (strict <)

Thanks for your amazing work.

Support for multiple Terraform modules.

Because of its performance characteristics, a best-practice at every org I've been involved in is to have multiple separate Terraform modules. That could be per-environment, or per-environment-per-system. In my case, I have 3 modules for AWS (one per env), 3 for GCP (one per env; soon to be 4), and so on (we also use the DataDog, and Github providers with plans to add a couple more). Looking at the source to this action, I don't see a means to handle this.

If such a mechanism exists, can you point me at relevant documentation? If such a mechanism does not exist, I'd love to see it added.

[bug] terraform_workspace is broken

example of yaml:

      - name: Run infracost diff
        uses: infracost/[email protected]
        env:
          INFRACOST_API_KEY: ${{ secrets.INFRACOST_API_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          path: .
          entrypoint: /scripts/ci/diff.sh
          usage_file: infracost-usage.yml
          post_condition: '{"always": true}'
          terraform_workspace: staging

output:

"/home/runner/work/infrastructure/infrastructure":"/github/workspace" infracost/infracost:latest  "." "" "staging" "infracost-usage.yml" "" "" "{\"always\": true}"
Running infracost breakdown using:
  $ staging --terraform-workspace staging --usage-file infracost-usage.yml
sh: staging: not found

somehow instead of calling infracost the container is calling to staging that such command doesn't exist.

thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.