Terraform Variable Generator
Build a variables.tf from a list of name/type/description/default rows, runs entirely in your browser.
About this tool
Add one or more variables, each with a name, a Terraform type (string, number, bool, list(string), or map(string)), an optional description, and an optional default, and get back a correctly formatted variables.tf with one variable block per row. Defaults are formatted for their type automatically: a list(string) default is entered as a comma-separated list and rendered as a proper HCL list literal, a map(string) default as comma-separated key=value pairs rendered as a proper HCL map.
Leaving a default blank is meaningful, not just empty: a Terraform variable with no default becomes required, and Terraform will prompt for (or fail without) a value at apply time. This tool only emits a default line when one is actually given, so a variable you leave blank stays genuinely required rather than silently getting an empty-string default.
Frequently asked questions
- What happens if I leave the default blank?
- The generated block has no default line at all, which is what makes a Terraform variable required. Terraform will refuse to plan or apply without a value being supplied some other way (a .tfvars file, -var flag, or interactive prompt).
- How do I write a default for a list(string) or map(string) variable?
- For list(string), enter comma-separated values, e.g. "us-east-1a, us-east-1b". For map(string), enter comma-separated key=value pairs, e.g. "env=prod, team=platform". Both are converted into properly quoted HCL literals.
- Does this validate that my variable names are legal Terraform identifiers?
- Yes. A name must start with a letter or underscore and contain only letters, numbers, underscores, and hyphens, the same rule Terraform itself enforces; an invalid name is rejected with an error before any output is generated.
- Is my input sent anywhere?
- No. The file is assembled entirely in your browser, no network request is made.
Continue learning
- DocumentationTerraform BasicsHow Terraform's state model, providers, and plan/apply workflow make infrastructure reviewable like code, plus the state pitfalls that trip up teams.
- BlogTerraform Troubleshooting Guide: Fix the Errors Engineers Actually HitDiagnose Terraform initialization, validation, provider, authentication, state, drift, import, replacement, timeout, and CI failures with a safe workflow.
- ToolTerraform Module GeneratorScaffold a reusable module’s main.tf/variables.tf/outputs.tf from a list of variable and output names, runs entirely in your browser.
- DocumentationBash FundamentalsBash scripting from variables to functions, plus the quoting and exit-status habits that separate a script that looks right from one that fails safely.
- BlogHow to Build a Production-Ready Azure Environment with TerraformBuild an Azure foundation with Terraform remote state, controlled outbound access, private endpoints, Key Vault, Storage, monitoring, verification, and cleanup.
- ToolDockerfile GeneratorGenerate a working Dockerfile for Node.js, Python, Go, or a static site, runs entirely in your browser.