Skip to main content

November 2021: New AWS/Azure/Google resources and composable GitHub Actions

· 8 min read

Summary: we're excited to announce Infracost v0.9.14 and our new composable GitHub Actions 🎉 This release also includes new GitHub comment and Slack message output formats, 6 new AWS/Azure/Google resources, a summary table in PR comments, improved CLI output, and faster runs. We recommend everyone to upgrade!

How did we get here?

It's a bit noisy! We'd received a bunch of feedback about Infracost's CI/CD integrations - let's face it, everyone's Terraform workflow is different — so in November we decided to try a new approach… Let's rewind for a second: around a year ago, we made an 86-line bash script that ran Infracost on a repo's main and pull request branches, it then ran git diff with some tricks on the CLI output, and curled it to GitHub to post a PR comment as you can see below:

The original Infracost pull request comment

As with most useful bash scripts, it grew arms and legs over time and went from 86 lines to 647! It handled a bunch of workflows, and edge cases, in GitHub, GitLab, CircleCI, Bitbucket and Azure DevOps - it even made you breakfast! The original bash script was packaged-up in a Docker image, which meant it also had to include Terraform, Terragrunt, git and a bunch of other stuff. We then had to add multiple Terraform versions to support everyone's workflows and the image grew to ~1GB uncompressed 🤮

So in November we went back to the drawing board, put away the 1 year old bash script, and developed a new composable way of using Infracost in CI/CD pipelines. Thank you bash, you served us well and we still love you for prototyping in CI/CD.

New composable GitHub Actions

The new Infracost GitHub Actions provide a composable way of using Infracost in your workflow. These native JS actions can be used to install Infracost, and comment on pull requests using different behaviors so you can control the noise level (described below). This enables the Infracost output to be used by other actions too, e.g. to set cost policies or post messages to Slack!

If you used our old infracost-gh-actions repo, please follow our migration guide to use the new new actions repo. The infracost-gh-actions repo will be deprecated in the next Infracost release but will continue to work without issues.

A demo of the new Infracost GitHub Actions

Install Infracost

The "setup" action installs the Infracost CLI using SemVer ranges. This enables you to automatically get the latest backward compatible changes in the 0.9 release (e.g. new resources/features and bug fixes) without worrying about CI/CD pipelines breaking.

You can use other actions to install required versions of Terraform and Terragrunt.

Configure pull request comments

The "comment" action lets you configure how pull request comments are posted using a behavior and a target attribute.

Behavior describes how and when comments should be posted; we support four options:

  • update: Create a single comment and update it on changes. This is a good default. The GitHub comments UI shows what/when changed when the comment is updated. Pull request followers will only be notified on the comment create (not updates), and the comment will stay at the same location in the comment history.
  • delete-and-new: Delete previous cost estimate comments and create a new one. Pull request followers will be notified on each comment.
  • hide-and-new: Minimize previous cost estimate comments and create a new one. Pull request followers will be notified on each comment.
  • new: Create a new cost estimate comment. Pull request followers will be notified on each comment.

The target-type describes where the comment should be posted against, which can be either pull-request (default) or commit.


We've created 10 examples of how the Infracost actions can be used in different workflows, including multi-project setups using a build matrix, setting cost or percentage thresholds for comments using the Infracost JSON output, and posting cost estimates to Slack.

We'd love to see the community contribute their examples too; we've even developed automated tests for the examples 😎

New output formats

The infracost output command can be used to combine and output Infracost JSON files in different formats. This is useful when you want to combine cost estimates across different projects, e.g. Terraform mono repos or Terragrunt projects, or produce different formats from the same cost estimate, e.g. create a GitHub comment, and a Slack message when a threshold is crossed. We've added two new formats to this command:

  • github-comment: produces a Github-flavored Markdown comment. This is used internally by the new Infracost GitHub Actions; if you use GitHub with other CI/CD systems, you can also use this format to create comments that can then posted to GitHub.

    GitHub comment output format
  • slack-message: produces a Slack-flavored Markdown message. Slack message blocks have a 3000 char limit so the Infracost CLI automatically truncates the middle of slack-message output format if required.

    Slack message output format

New resources

We added support for 6 new resources:

  • AWS: Transfer Family, RDS additional backup storage
  • Azure: Storage Account (V2), Front Door, Private Link Endpoints
  • Google: Secret Manager

Our automated tests caught the price changes AWS announced at re:Invent and we've updated CLI to handle them.

Create GitHub issues if you need support for other resources. Checkout our contributing guide if you'd like to join the 50+ community members who have added resource mappings already. Once a mapping has been coded, the whole community enjoys the benefits.

Summary table in PR comments

Pull/merge request comments in GitHub, GitLab and Azure DevOps Repos now show a summary table. This enables you to quickly understand the overall changes and review the detailed diff if the changes seem significant. Unfortunately we couldn't do the same for Bitbucket comments as they don't support HTML yet; please upvote this GitHub issue if you'd like us to use their markdown format instead.

Pull request summary table

Improved CLI output

Infracost CLI commands now include a summary of the resources at the bottom, which can be expanded to show details with the --show-skipped flag. The summary shows the total number of cloud resources, how many include usage-based costs, how many weren't estimated, and how many are free.

Resource summary at the bottom of CLI output

The CLI diff output has been simplified to show changes in one line, similar to how Terraform and Pulumi show changes. Previously we showed 2 lines: one showing the old resource being removed, and one showing the new resource being added.

One line diff output

Save to file

The Infracost breakdown, diff and output commands now support an --out-file flag, which can be used to save the output to a file. This is specially helpful when the --format flag is used as you can save the output and use it in subsequent actions.

Faster runs

The sync-usage-file flag now runs a lot faster as we've parallelized the API calls to fetch usage data from AWS CloudWatch. If you're using this feature, we highly recommend you upgrade!

Community highlights

We ❤️ seeing feedback, bug reports and pull requests from the community! To pick a few: Josh Niec and Maksym Vlasov made their first contributions, Simon-jt kept improving the Cloud Pricing API deployment, Pat Myron simplified a bunch of test files, and Hugo Rut and Sina Bakhtiari are making it easier for contributors to add resources.

Especial thanks to the many users who gave us feedback on our old GitHub Action, particularly:

Demo videos

Checkout the following four demo videos of our November updates:

  1. Infracost GitHub Actions
  2. New github-comment and slack-message outputs
  3. Estimating Azure storage (Have you ever seen a shopping cart without prices? That's what engineers experience when they buy cloud resources with infra-as-code tools!)
  4. Resource summary in the CLI

Help us!

Up next, we're focusing on the following areas. You keep upvoting and sharing your comments in the following GitHub discussions and we'll keep shipping Always be shipping!

  1. Sharing cost estimates
  2. Learning about your Infracost CI/CD journey
  3. Investigating cost policies
  4. Improving our Atlantis integration
  5. Composable GitLab CI Templates

Message me on Slack or Twitter if you have any questions!