FDE Times dataFDE jobs open 881▼8 Change in open roles over 7 days, like-for-like: roles from companies we started tracking this week are left outNew in 7 days 55Companies hiring 185Remote-friendly 25%Median US pay $201kTop hirer Databricks 98
中文VI

The newspaper of the Forward Deployed Engineer

Tools

Your client's cloud bill belongs in the pull request

Infracost estimates cost changes in CI before anything deploys, but it can only block a merge once the job is made a required status check.

ShareLinkedInFacebookX

In brief

  • Infracost estimates costs from Terraform, CloudFormation and AWS CDK on AWS, Azure and Google Cloud, then comments on the PR.
  • When a guardrail is triggered, the comment is posted first and then the job fails; the merge is blocked only if the job is a required status check.
  • Code is parsed on the CI runner; according to the docs, only the cost estimate and PR metadata are sent to Infracost Cloud.
Flow diagram: a pull request is opened, Infracost posts a cost comment on the PR, then the diff command exits with code 1 and the job fails. The flow then splits into two equal branches, depending on how the job is set in branch protection: if it is not required, the merge still goes through; if it is a required check, the merge is blocked (this branch is shaded orange).
When a change breaches a guardrail, Infracost posts its comment first, then fails the job. A merge is blocked only if the job is set as a required status check. Source: Infracost GitHub Actions documentation.

When Infracost’s founders raised money in 2021, they summed up the problem in one sentence: engineers spin up cloud resources, but nobody shows them the price until the bill arrives. For an FDE the gap hurts more, because the person opening the bill is the client, not you.

You write Terraform in the client’s repo, merge, deploy and move on. Three weeks later someone in the client’s finance team asks why cloud spend has gone up. By then the number is real money, and the deployment team has lost a little trust.

This is exactly the gap Infracost fills. It puts the estimate into the pull request, while the reviewer can still change what is being merged.

What it does, and with which tools

The official documentation describes Infracost as a tool that brings cloud cost into the engineering workflow earlier, rather than leaving it to the end. It supports Terraform, CloudFormation and AWS CDK, on AWS, Azure and Google Cloud. The stated goal is to catch cost problems in pull requests, before deployment.

When it launched on Hacker News (in YC’s W21 batch), Infracost introduced itself as an open-source cloud cost estimator that comments on Terraform PRs, and at first it supported only Terraform on AWS and Google Cloud.

The current GitHub README lists the Apache 2.0 licence. It also says that cost differences and policy checks are posted straight on the PR, inside the workflow you already use.

The free tier covers estimates for Terraform, CloudFormation and CDK, capped at 1000 runs a month. The Cloud tier adds Cost Guardrails, Autofix and custom price books. You need to know where that line falls before promising a client anything.

When should an FDE bring it out?

“How much will this change cost each month?” tends to come up in the middle of a demo. With Infracost, the answer is already in the PR, along with the difference from the current infrastructure. If the client has a hard budget for the project, Infracost’s homepage states the purpose of guardrails plainly: keeping every project launching within budget.

Handover is another good moment. After you leave, the client’s team keeps editing Terraform. An Infracost job that runs on every PR keeps warning them long after you have moved to another project.

A minimal GitHub Actions example

Picture opening a PR that adds a database module to a client’s RAG pipeline. According to the GitHub Actions guide, the Infracost job runs on every PR and posts two things: the cost estimate and the FinOps practices worth applying. Setup needs a secret holding the CLI token and the pull-requests: write permission for the workflow.

The skeleton below only shows where those three pieces go. The uppercase placeholders in angle brackets are blanks: the CLI install step, the environment variable name, the secret name and the diff arguments must be copied exactly from Infracost’s GitHub Actions guide.

name: infracost
on: pull_request

permissions:
  contents: read
  pull-requests: write   # without this, only the comment fails

jobs:
  infracost:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      # <INSTALL_INFRACOST_CLI_STEP>: copy from the official guide
      - name: Infracost diff
        run: infracost diff <ARGS_PER_DOCS>
        env:
          <CLI_TOKEN_VAR>: ${{ secrets.<CLI_TOKEN_SECRET_NAME> }}

The client’s reviewer no longer has to read HCL to guess the price. They read the comment, see how much the cost changes, and ask questions right in the PR, such as whether the configuration really needs to be that large.

Now suppose the module trips a guardrail. The documentation describes a precise order: the comment is posted first, then the diff command exits with code 1 and the job fails. The detail that matters is that a failed job is not enough to block a merge. The merge is blocked only when the job is set as a required status check in branch protection.

One more detail helps with debugging. If the workflow lacks write permission on the PR, the estimate still runs and is still uploaded; only the comment fails. So when a PR shows no comment, check the workflow’s permissions before suspecting Infracost itself.

Where does the client’s data go?

The client’s security team will ask this first. According to the guide, the code is parsed on the CI runner, and only the cost estimate and PR metadata are sent to Infracost Cloud. When filling in the client’s security questionnaire, quote exactly that, with a link to the original page, rather than paraphrasing it yourself.

Limits to state plainly to the client

Infracost’s number is an estimate calculated from code before deployment, not an invoice. It only sees changes that go through IaC and pull requests. Resources someone clicks into existence in the console are outside its view.

Its ability to block also depends on the repo’s configuration, not on the tool. And Cost Guardrails and Autofix belong to the Cloud tier. If the client is on the free tier only, do not promise automatic budget-based blocking.

Exercise: read the comment like a client reviewer

Set up the workflow on a personal Terraform repo, then open a test PR that adds a billable resource.

When Infracost’s comment appears, read it with three questions in mind: which resource changes the cost the most, whether the number matches what you expected before opening the PR, and what you would ask the PR’s author if this were a client’s repo.

Then run two experiments. Remove the pull-requests: write permission and confirm the estimate still runs while only the comment fails. Then turn on branch protection, make the job a required status check, and open a PR that makes diff exit with code 1, so you can see the merge blocked for yourself.

What to learn first

Get two foundations solid: enough Terraform to read an infrastructure change, and enough GitHub Actions to configure secrets, permissions and branch protection. Infracost relies entirely on both. Once you have them, installing it takes far less time than explaining to a client why they should.

The exercise above also doubles as a portfolio piece. Keep the test PR with its cost comment and a screenshot of the blocked merge, and in an FDE interview tell the detail most people miss: a failed job blocks nothing unless the repo requires that check. The interviewer will see that you understand the mechanism, not just the tool’s name.

Clients rarely remember how fast you deployed. They remember that the month-end bill held no surprises.

Was this article useful?

Use with your AI assistantAsk Claude ↗Ask ChatGPT ↗
7 sources
Read next on the roadmap · Stage 5: DeploymentHand over a repo with secrets without waiting for the client's VaultSOPS encrypts only the values, so git diffs stay readable, and the age keys that decrypt them stay with the client.