Terraform Variable Generator
Define your Terraform input variables using the form and instantly get the corresponding
variables.tf and
terraform.tfvars output.
Supports all primitive and collection types, sensitive values, default values, and validation blocks.
Frequently Asked Questions
What does this tool generate?▼
This tool generates two files: variables.tf (the variable declarations with type, description, default, sensitive flag, and optional validation blocks) and terraform.tfvars (the variable value assignments). These are the standard Terraform files for defining and setting input variables.
What Terraform variable types are supported?▼
All primitive types: string, number, bool. Collection types: list(string), list(number), map(string), set(string). And 'any' for untyped variables. For complex nested types like object({}) or tuple([]), you can type them manually in the HCL default value field.
What is the difference between variables.tf and terraform.tfvars?▼
variables.tf declares the variables — their name, type, description, default, and validation rules. It's part of your module's interface and should be committed to source control. terraform.tfvars provides actual values for those variables. For sensitive or environment-specific values, use a .tfvars file that is gitignored, or pass values via environment variables (TF_VAR_name) or -var flags.
What does 'sensitive = true' do?▼
Marking a variable as sensitive tells Terraform to redact its value in plan output, apply output, and state file display. The value is still stored in state, but Terraform won't print it in logs. This is recommended for passwords, API keys, and private keys. You should still encrypt your state backend (S3 + KMS, Terraform Cloud) for full protection.
How do validation blocks work?▼
Validation blocks (introduced in Terraform 0.13) let you add custom constraints to variables. The 'condition' is a Terraform expression that must evaluate to true for the value to be accepted — you can use var.<name> to reference the variable being validated. The 'error_message' is shown when validation fails. Example: condition = var.instance_count >= 1 && var.instance_count <= 100.
What is the correct HCL format for default values?▼
String defaults must be quoted: "us-east-1". Number defaults are plain: 42. Boolean defaults: true or false. List defaults: ["a", "b", "c"]. Map defaults: { key = "value" }. Set defaults use the same syntax as list. Leave the default field empty for required variables (no default means Terraform will prompt for the value or error if not provided).
Related Products
on GumroadDevToolkit Starter Kit
A ready-to-deploy developer tools website with 12 built-in tools. Astro + Preact + Tailwind. Deploy to Cloudflare Pages for free. Built-in SEO, dark mode, and ad-ready layout.
Buy on Gumroad →Premium Workflow Pack
Production-grade workflows, architecture guides, and deployment scripts for teams that ship. 10 advanced CI/CD workflows (blue-green, canary, E2E, security), 5 architecture deep-dives, code review checklist, PR process guide, and 5 battle-tested Bash deployment scripts.
Buy on Gumroad →GitHub Actions CI/CD Templates Pack
12 production-ready GitHub Actions workflow templates covering Node.js, Python, Docker, multi-environment deployments, security scanning, and auto-changelog. Copy, paste, ship.
Buy on Gumroad →You Might Also Need
Terraform Variable Builder
Build Terraform variable declarations for variables.tf with a visual form. Set type, default value, description, sensitivity, and validation rules.
Open free tool →
Terraform Variable Validator
Validate your Terraform variables.tf online. Catches missing type constraints, undocumented variables, unmasked secrets, and type/default mismatches. Runs 100% in your browser.
Open free tool →
Terraform State Inspector
Parse and inspect Terraform state files. View resource inventory, provider dependencies, module breakdown, and identify drift indicators like zero-instance resources.
Open free tool →
More Free Tools
Related Articles
Terraform vs Pulumi 2026: Infrastructure as Code Comparison with Code Examples
Complete Terraform vs Pulumi comparison for 2026 — syntax, state management, multi-cloud support, testing, pricing, and when to choose each IaC tool.
AWS CDK vs Terraform vs Pulumi: Infrastructure as Code Comparison 2026
Complete comparison of AWS CDK, Terraform, and Pulumi for infrastructure as code in 2026 — language support, state management, multi-cloud, community, and when to use each.
Pulumi vs Terraform 2026: Which IaC Tool Should You Choose?
A deep comparison of Pulumi and Terraform for infrastructure as code in 2026. Covers syntax, state management, provider ecosystem, team adoption, and when to choose each tool.
Terraform vs Pulumi vs AWS CDK: Infrastructure as Code Comparison 2026
Complete comparison of Terraform, Pulumi, and AWS CDK for infrastructure as code in 2026. Covers language support, state management, learning curve, ecosystem, cloud support, pricing, and when to use each tool.
Terraform vs Pulumi: Infrastructure as Code Comparison 2026
In-depth comparison of Terraform and Pulumi for Infrastructure as Code in 2026. Covers HCL vs real programming languages, state management, provider ecosystem, and when to use each.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$9/mo after trial · Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →