Git Product home page Git Product logo

infracost's Introduction

Infracost logo

Community Slack channel Build Status Docker Image Tweet

Getting started

Infracost shows cloud cost estimates for Terraform projects. It helps developers, devops and others to quickly see the cost breakdown and compare different options upfront.

Example Infracost output

Installation

  1. Assuming Terraform is already installed, get the latest Infracost release:

    macOS Homebrew:

    brew install infracost

    Linux/macOS manual:

    os=$(uname | tr '[:upper:]' '[:lower:]') && \
    curl -s -L https://github.com/infracost/infracost/releases/latest/download/infracost-$os-amd64.tar.gz | tar xz -C /tmp && \
    sudo mv /tmp/infracost-$os-amd64 /usr/local/bin/infracost

    Docker and Windows users see here.

  2. Use our free Cloud Pricing API by registering for an API key:

    infracost register

    The key is saved in ~/.config/infracost/credentials.yml. If you prefer, you can run your own Cloud Pricing API.

  3. Run infracost using our example Terraform project to see how it works.

    git clone https://github.com/infracost/example-terraform.git
    cd example-terraform
    
    # You can play with `aws/main.tf` and `aws/infracost-usage.yml`, and re-run infracost to compare costs
    infracost --terraform-dir aws --usage-file aws/infracost-usage.yml

Please watch/star this repo as we add new cloud resources every week or so.

Basic usage

There are 4 usage methods for Infracost depending on your use-case. The following is the default method. Point to the Terraform directory using --terraform-dir and pass any required Terraform flags using --terraform-plan-flags. Internally Infracost runs Terraform init, plan and show; init requires cloud credentials to be set, e.g. via the usual AWS_ACCESS_KEY_ID environment variables. This method works with remote state too.

infracost --terraform-dir /path/to/code --terraform-plan-flags "-var-file=myvars.tfvars"

Read the getting started docs for details, including notes for Terragrunt and Terraform Cloud users.

As mentioned in the FAQ, you can run Infracost in your Terraform directories without worrying about security or privacy issues as no cloud credentials, secrets, tags or Terraform resource identifiers are sent to the open-source Cloud Pricing API. Infracost does not make any changes to your Terraform state or cloud resources.

CI/CD integrations

The following CI/CD integrations can be used to automatically add a comment showing the cost estimate diff between a pull request and the master branch:

If you run into any issues with CI/CD integrations, please join our community Slack channel, we'd be happy to guide you through it.

Example infracost diff usage

Supported clouds and resources

Infracost supports over 70 AWS and Google resources, Azure is planned. The quickest way to find out if your Terraform resources are supported is to run Infracost with the --show-skipped option. This shows the unsupported resources, some of which might be free. Please watch this repo for new releases as we add new cloud resources every week or so.

See this page for details on cost estimation of usage-based resources.

Contributing

Issues and pull requests are welcome! For development details, see the contributing file. For major changes, please open an issue first to discuss what you would like to change.

Join our community Slack channel, we are a friendly bunch and happy to help you get started :)

License

Apache License 2.0

infracost's People

Contributors

aliscott avatar alikhajeh1 avatar actions-user avatar sinabakh avatar dependabot[bot] avatar robh007 avatar sashman avatar m-yosefpor avatar chenrui333 avatar anton-yurchenko avatar hassankhosseini avatar bmbferreira avatar ekifel avatar syphernl avatar oasys avatar unfor19 avatar miladibra10 avatar mohammadkarimi23 avatar richardj-bsquare avatar joeunrue avatar hakamadare avatar thomaslorentsen avatar

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.