richardj-bsquare / infracost

Cloud cost estimates for Terraform in your CLI and pull requests πŸ’°πŸ“‰

Home Page:https://infracost.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Infracost logo

Docs Build Status Docker Image Tweet

Community Slack Schedule setup call

Infracost shows cloud cost estimates for a Terraform project. 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/config.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 re-run infracost to compare costs
    infracost --tfdir aws

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 --tfdir and pass any required Terraform flags using --tfflags. 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 --tfdir /path/to/code --tfflags "-var-file=myvars.tfvars"

Checkout the docs site for additional usage options, including notes for Terragrunt and Terraform Cloud users.

CI/CD integrations

The Infracost GitHub Action, GitLab CI template or CircleCI Orb can be used to automatically add a comment showing the cost estimate diff between a pull/merge 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 50 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 :)

We're looking for people to help us add new AWS and Google resources and are willing to pay for it. Please direct-message Ali Khajeh-Hosseini on our community Slack channel to find out more.

License

Apache License 2.0

About

Cloud cost estimates for Terraform in your CLI and pull requests πŸ’°πŸ“‰

https://infracost.io

License:Apache License 2.0


Languages

Language:Go 96.2%Language:Shell 3.1%Language:Makefile 0.4%Language:Dockerfile 0.2%