Run OpenInfraQuote (oiq
) on a Terraform plan file and post a cost estimate as a pull request comment.
To use OpenInfraQuote in your GitHub Actions workflow:
-
Ensure your Terraform plan file is written in JSON format:
terraform init terraform plan -out=tfplan.binary terraform show -json tfplan.binary > tfplan.json
-
Add the OpenInfraQuote GitHub Action as a step after the plan is generated:
- name: Run OpenInfraQuote uses: terrateamio/openinfraquote-action@v1 with: plan-path: tfplan.json comment-on-pr: true
If you're setting up a new workflow, here's a minimal example:
name: Terraform Plan
on:
pull_request:
paths:
- '**.tf'
- '**.tfvars'
permissions:
pull-requests: write
jobs:
plan:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
- name: Terraform Init
run: terraform init
- name: Terraform Plan
run: terraform plan -out=tfplan.binary
- name: Convert plan to JSON
run: terraform show -json tfplan.binary > tfplan.json
- name: Run OpenInfraQuote
uses: terrateamio/openinfraquote-action@v1
with:
plan-path: tfplan.json
comment-on-pr: true
Name | Description | Default |
---|---|---|
plan-path |
Path to the Terraform JSON plan file | tfplan.json |
comment-on-pr |
Whether to post a cost estimate as a comment on the PR | true |
region |
Optional region to pass to oiq price (e.g. us-east-1 ) |
(empty) |
When comment-on-pr
is enabled and the estimate is non-zero, this action posts a PR comment that includes:
- The estimated monthly cost range (min/max)
- A table of resource-level cost changes
If the estimate is zero, no comment is posted.
- This action processes a single Terraform plan file.
- If you manage multiple plans (e.g., with a matrix), run the action once per plan.
- Cost data is sourced from the public price sheet.
- No API key or account is required.
MPL-2.0