GitHub Action for Infracost. See cloud cost estimates for Terraform in pull requests. ๐ฐ๐ Love your cloud bill!
APACHE-2.0 License
Full Changelog: https://github.com/infracost/actions/compare/v3.0.0...v3.0.1
Published by aliscott 8 months ago
Full Changelog: https://github.com/infracost/actions/compare/v2.1.0...v3.0.0
Published by tim775 almost 2 years ago
infracost/actions/setup@v2
now uses node 16.Full Changelog: https://github.com/infracost/actions/compare/v2.0.0...v2.1.0
Published by aliscott over 2 years ago
See the GitHub Actions migration guide in the docs for migrating the Infracost GitHub Action v1 to v2.
Back in February 2022, we started an experiment to estimate costs by parsing Terraform HCL code directly. We're excited to announce that the experiment worked! So in v0.10 we've removed the experimental --terraform-parse-hcl
flag and made HCL parsing the default behavior.
Going forward, we'll support two ways to run Infracost with Terraform via --path
:
# Terraform variables can be set using --terraform-var-file or --terraform-var
infracost breakdown --path /code
cd /code
terraform init
terraform plan -out tfplan.binary
terraform show -json tfplan.binary > plan.json
infracost breakdown --path plan.json
Infracost can now generate cost estimates without needing a Terraform plan. This removes our dependency on the Terraform binary altogether, which means no more terraform init
or terraform plan
.
That, in turn, means a super-fast CLI: Infracost used to take around 50 seconds to run on our internal Terraform mono-repo, that's now reduced to 2 seconds. ๐
Running terraform plan
requires users to have cloud credentials and Terraform secrets. The main reason we created the Infracost CLI first, instead of a web API, was so it could parse the Terraform plan JSON locally to extract cost-related parameters (e.g. instance type). Thus credentials and secrets were not sent anywhere.
Whilst this worked and was safe, it still posed a question: is there a way to avoid setting credentials or secrets altogether? Removing our dependency on terraform plan
gave us a way to do that.
Not needing cloud credentials, or even knowledge of how to generate a Terraform plan, means that any engineer who has access to code repos can generate cost estimates!
This also opens the door for cost estimates to be put everywhere: Infra-as-Code repo readmes, Terraform module readmes, Visual Studio, and even in continuous integration systems where a Terraform plan does not exist (not everyone runs Terraform via continuous deployment systems).
To make infracost diff
work without a Terraform plan, we introduced a new --compare-to infracost-base.json
flag. This enables a git-based cost diff to be produced, e.g.:
git checkout main
infracost breakdown --path /code --format json --out-file infracost-base.json
git checkout my-branch
infracost diff --path /code --compare-to infracost-base.json
The infracost diff
command can now also be used to compare Infracost runs. Assuming you generated the files infracost-last-week.json
and infracost-today.json
using the infracost breakdown --path /code --format json
command, you can compare them using:
infracost diff --path infracost-today.json --compare-to infracost-last-week.json
Setting the --path
flag to a top-level repo directory will now attempt to process all projects automatically by:
.auto.tfvars
extension (similar to what Terraform does).TF_VAR_
prefix (similar to what Terraform does).If this does not work for your use-case, use a config-file and run infracost breakdown --config-file=infracost.yml
, for example:
# infracost.yml
version: 0.1
projects:
- path: prod
terraform_var_files:
- prod.tfvars
- us-east.tfvars
- path: dev
terraform_var_files:
- dev.tfvars
If you previously used the following two options to see the cost breakdown of the current Terraform state, you can now just run infracost breakdown --path /code
against the already-deployed branch.
--terraform-use-state
flag has been removed.If you previously ran Infracost with a Terraform plan binary file, you should now generate a plan JSON file and use that instead:
terraform show -json tfplan.binary > plan.json
infracost breakdown --path plan.json
INFRACOST_TERRAGRUNT_FLAGS
environment variable is no longer supported as Infracost parses HCL code directly. Comment on this issue if you'd like a way to exclude certain directories.As a workaround you can still generate plan JSONs for these projects and pass the plan JSON to Infracost to get a cost estimate. We are looking to fix these issues in upcoming patch releases.
Full Changelog: https://github.com/infracost/actions/compare/v1...v2.0.0
Published by aliscott over 2 years ago
Full Changelog: https://github.com/infracost/actions/compare/v1.1.1...v1.1.2
Published by alikhajeh1 over 2 years ago
This release includes small documentation and example fixes (listed below), the only behavior change is:
Full Changelog: https://github.com/infracost/actions/compare/v1.1.0...v1.1.1
Published by aliscott almost 3 years ago
Full Changelog: https://github.com/infracost/actions/compare/v1.0.2...v1.1.0
Published by aliscott almost 3 years ago
tag
input for comment action by @aliscott in https://github.com/infracost/actions/pull/35
Full Changelog: https://github.com/infracost/actions/compare/v1.0.1...v1.0.2
Published by tim775 almost 3 years ago
This is the intial release of our improved GitHub actions library which includes ๐:
If you used the old infracost-gh-actions repo, we recommend you follow our migration guide to use this new repo.
Thanks to the many users who gave us feedback on our old GitHub Action especially โค๏ธ :