IaC Cost Estimation CI Gate Prompt
Wire Infracost (or equivalent) into pull-request CI so infrastructure changes show a cost diff and breach a budget gate before merge — turning cloud spend into a reviewable, policy-enforced number.
- Target user
- Platform / FinOps engineers adding cost visibility to IaC pipelines
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a FinOps-minded platform engineer who made cloud cost a first-class PR review signal: every infra change posts a cost diff comment, and changes over a threshold require explicit sign-off. You want estimates, not surprises on the next invoice. I will provide: - The IaC tool (Terraform/OpenTofu, Pulumi, CloudFormation) and CI system - Our cloud(s), and any reserved/savings-plan or negotiated pricing - Budget thresholds and who approves overages Your job: 1. **Pick the tool & its limits** — Infracost for Terraform/Pulumi/CloudFormation; be explicit that estimates are list-price approximations: usage-based costs (egress, requests, Lambda invocations) need usage files, and commitment discounts (RIs/SPs/CUDs) won't show. Set reviewer expectations accordingly. 2. **PR cost-diff comment** — generate the CI step that runs against the plan, posts a breakdown comment (resource-level monthly delta), and updates the same comment on re-push instead of spamming. 3. **Budget policy gate** — define thresholds (e.g. warn at +$200/mo, block at +$1000/mo or +20%), implement them with `infracost comment`'s policy / a conftest rule on the Infracost JSON, and require a labeled approval to override. 4. **Usage-based accuracy** — add an `infracost-usage.yml` for the big usage drivers (data transfer, S3 requests, NAT gateway, Lambda) so estimates aren't wildly low. Show which resources most need it. 5. **Baseline & drift** — store a cost baseline so the diff is change-over-current, not absolute; flag the top cost contributors in the repo. 6. **Right-sizing nudges** — have the bot suggest cheaper-by-default alternatives (gp3 over gp2, graviton, autoscaling floors, lifecycle policies) when it sees obvious waste. 7. **Org rollout** — self-hosted vs cloud pricing API, API key handling, and how to make the gate advisory first, then enforcing. Output as: (a) the CI job, (b) the cost-policy (conftest/Infracost policy) with thresholds, (c) an example usage file, (d) a sample PR comment, (e) the advisory→enforce rollout plan. Bias toward: change-over-baseline diffs, usage files for the heavy hitters, advisory-before-blocking, honest caveats about estimate accuracy.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
OpenTofu Native Test Framework Module Validation Prompt
Build a real test suite for a reusable OpenTofu module using the native `tofu test` framework — combining fast plan-only assertions, targeted apply-and-verify runs, mocked providers, and variable-validation coverage into a CI gate that catches regressions before they reach state.
-
Ansible-lint Custom Ruleset and Profile Configuration Prompt
Author an .ansible-lint configuration that selects the right enforcement profile, tunes skip/warn lists, and adds custom rules so CI fails on real problems without drowning teams in noise.
-
Helm Chart Testing Strategy Prompt
Build a layered test suite for Helm charts — lint, schema-validated values, golden-file template tests, and helm test hooks against a kind cluster — so a values change can't silently break rendered manifests.
-
AWS CDK Escape Hatches & L1 Override Prompt
Use CDK escape hatches (addPropertyOverride, addOverride, addDeletionOverride, and L2-to-L1 access) to set properties the L2 construct does not expose, without forking constructs or dropping to raw CloudFormation.
More Infrastructure as Code prompts & error guides
Browse every Infrastructure as Code prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.