I built a 3,000-pair Terraform error-fix dataset - and every fix is machine-verified
AI coding assistants are decent at writing Terraform. Ask one to debug a broken config and it falls apart: it guesses, it hallucinates functions, it "fixes" things that were never broken.
I think part of the problem is the training data. Most code datasets teach models to generate code from scratch. Almost none teach them to go from a real error message to a correct fix - because that data barely exists in a clean, verified form.
So I built it: 3,000 Terraform error → fix pairs, where every single fix was machine-verified by actually running terraform validate. No scraped Stack Overflow answers, no paraphrased errors, no "probably works" fixes.
What a record looks like
Each record has the real error output, the broken HCL, the fixed HCL, and a short explanation:
{
"id": "tf-0001",
"category": "functions",
"terraform_version": "1.9",
"error_message": "Error: Call to unknown function\n\non main.tf line 2, in output \"web\":\n 2: value = frobnicate(\"hello\")\n\nThere is no function named \"frobnicate\".",
"broken_hcl": "output \"web\" {\nvalue = frobnicate(\"hello\")\n}\n",
"fixed_hcl": "output \"web\" {\nvalue = upper(\"hello\")\n}\n",
"explanation": "frobnicate is not a Terraform built-in function, so the call fails. Replacing it with a real function such as upper() fixes the expression.",
"difficulty": "beginner"
}
That error_message is not something I wrote - it's the actual stderr captured from terraform validate. The broken snippet really fails, and the fixed snippet really passes.
Three real examples
1. The typo Terraform actually catches for you (reference / beginner)
Error: Reference to undeclared input variable on main.tf line 5, in output "web": 5: value = var.environmente An input variable with the name "environmente" has not been declared. Did you mean "environment"?
Fix: var.environmente → var.environment. One character. This is the kind of error a model should learn to spot instantly - and the kind it currently "fixes" by inventing a new variable.
2. Type mismatch in a default value (variable / beginner)
# broken
variable "environment" {
type = number
default = "abc"
}
Error: Invalid default value for variable This default value is not compatible with the variable's type constraint: a number is required.
Fix: default = 8080. The pattern generalizes: a wrong-typed default is one of the most common beginner errors, and the fix is always "make the value match the declared type."
3. The missing brace (syntax / beginner)
Error: Unclosed configuration block on main.tf line 1, in variable "environment": 1: variable "environment" { There is no closing brace for this block before the end of the file.
Fix: add the closing }. Trivial for a human, and exactly the sort of thing a fine-tuned model should nail 100% of the time - if it has ever seen the pair.
How it was made (the honest version)
This dataset is 100% synthetic. Nothing was scraped from GitHub, Stack Overflow, or any forum. The process:
- A cloud infrastructure engineer (7+ years of Terraform) hand-authored ~176 error patterns across HCL syntax, references, variables, functions, types, logic, count /
for_each/dynamic, providers, state, locals, and outputs. - Each pattern was instantiated with varied identifiers and values.
- Every broken snippet was executed with
terraform validate(v1.9.8, provider-free configs) and the real error output was captured. - Every fixed snippet was executed with
terraform validateand required to pass (exit 0). Any pattern that failed this was fixed or dropped - never silently skipped. - Automated scans: 0 secrets/PII hits, 0 exact duplicates.
The QC numbers: 3,000/3,000 fixed snippets pass validation, 3,000/3,000 broken snippets produce a real error, 0 cross-split leakage (verified by hash).
What's inside
- 3,000 records across 11 categories and 3 difficulty levels (1,200 beginner / 1,200 intermediate / 600 advanced)
- Train/val/test splits (2,400 / 300 / 300) with zero leakage between splits
- JSONL + Parquet formats - loads in one line with pandas, DuckDB, or 🤗 datasets
- Datasheet + QC report documenting exactly how the data was made, what's in it, and its limits
import pandas as pd
df = pd.read_json("terraform-error-fix-pro-train.jsonl", lines=True)
print(df["category"].value_counts())
The limits, stated plainly
I don't want anyone to buy this under a false impression, so here are the real limits:
- It's synthetic. The errors are real
terraform validateoutput, but the configs were authored, not collected from production incidents. It teaches the shape of errors and fixes, not war stories. - Category skew. functions is 38.7% of the data (1,160 of 3,000). That's because function misuse has the most distinct failure modes - but if you need a balanced category mix, you should know.
- Provider-free configs. The snippets validate without providers, so provider-specific errors (AWS/Azure resource arguments) are out of scope.
- Terraform 1.9.8. Error wording is version-specific; newer Terraform versions may phrase some errors differently.
What it's for
- Supervised fine-tuning of code assistants for Terraform troubleshooting
- Evaluation benchmark for error-diagnosis accuracy (the test split is a clean 300)
- RAG / retrieval examples for IaC help bots
Try it free
There's a free sample: 300 pairs (same format, same verification, CC-BY-4.0) - enough to check whether the data fits your pipeline before spending anything:
👉 Free Lite sample (300 pairs): https://kitforgelab.gumroad.com/l/cuppd
The full PRO dataset (3,000 pairs, JSONL + Parquet, splits, datasheet, commercial Team License) is $25:
👉 PRO dataset: https://kitforgelab.gumroad.com/l/terraform-error-fix-dataset-pro
If you fine-tune on it, I'd genuinely love to hear how it performs - especially on the test split. The whole point of verifying every fix mechanically was to make the benchmark trustworthy, and the only way to know if that paid off is people actually using it.
Built by KitForge. Questions: reply to your Gumroad receipt email, or find me on Threads @kitforgelab.
Comments
No comments yet. Start the discussion.