All Tools View Categories About Contact Privacy

Terraform main.tf Generator

Build a Terraform main.tf file (HCL) with resources, locals and outputs.

Runs entirely in your browser - nothing is uploaded and no cloud connection is made.
0
blocks
0
resources
Your generated main.tf will appear here.

About Terraform main.tf Generator

The main.tf file is the heart of most Terraform modules: it declares the resources that actually provision infrastructure, plus the locals and outputs that shape how that infrastructure is exposed. The Terraform main.tf Generator assembles a complete, valid main.tf from a form, so you can go from a mental sketch of a module to paste-ready HCL without remembering every quote, brace and label rule.

Add one or more resource blocks, each with a provider type, a name validated as a Terraform identifier, optional count and for_each meta-arguments, and a list of typed attributes. Then add an optional locals block and optional output blocks, including sensitive outputs. The generator emits correctly structured HCL with resources separated by blank lines and outputs marked sensitive where you asked. Everything runs locally in your browser, so no credentials, state or plan is uploaded. It is perfect for scaffolding a new module, teaching the resource block shape, or building a quick demo file for a workshop.

Because the output is ordinary HCL, it drops straight into a module directory and validates with terraform validate. The live block and resource counts give you an immediate sense of scope, which is handy when a module is growing and you want to confirm at a glance how many resources and outputs it will declare.

A further benefit is consistency across a team: when everyone starts from the same generated shape, modules look alike, which shortens reviews and reduces the chance that a resource is missing a required attribute. The form nudges you to fill in the common fields first, so a generated main.tf is a solid baseline you then refine rather than a blank page.

Features

  • Resources - any provider type with typed attributes.
  • Meta-arguments - optional count and for_each per resource.
  • Locals - an optional locals block with named values.
  • Outputs - optional outputs, including sensitive ones.
  • Identifier validation - resource and output names are checked.
  • Live stats - block and resource counts update with the output.
  • Consistent shape - a shared starting structure keeps modules uniform across a team.
  • Copy / Download / Print - export main.tf wherever you need it.
  • Copy as Markdown - a fenced block for docs and pull requests.
  • Word-wrap toggle - keep long attribute lines readable.
  • Example presets - realistic samples one click away.
  • Sensitive aware - mark outputs sensitive to keep secrets out of plan output.
  • Private - assembled in your browser, nothing leaves the page.

How to Use

  1. Click + Add resource and enter a provider type and a valid name.
  2. Add attributes for the resource, choosing a type for each value.
  3. Set count or for_each if the resource is repeated.
  4. Add a locals block (optional) with named values.
  5. Add outputs (optional), marking any that are sensitive.
  6. Click Generate HCL to build the main.tf.
  7. Review the stats and any errors on the right.
  8. Toggle word wrap if any attribute line is long.
  9. Use Copy Markdown to share the file in a review thread.
  10. Export by copying, copying Markdown, downloading main.tf or printing.
  11. Load a sample or clear to reset the form.

Examples

Example. Add one resource of type aws_instance named web with attributes ami and instance_type, plus a locals block holding common_tags and an output named instance_id exposing aws_instance.web.id (not sensitive). The generator emits a resource block, a locals block and an output block separated by blank lines, with the resource count reading one and the block count reading three. Marking the output sensitive would add sensitive = true to its body, which is exactly how you stop a secret from appearing in plan output.

If you instead choose the two-resource preset, the resource count rises to two while the block count rises to three once the locals and output are included, illustrating how the stats track module scope as you build. Removing the locals block would drop the block count by one without changing the resource count, which is a quick way to confirm what each section contributes to the final file.

Benefits

  • Correct schema - a valid main.tf every time.
  • Flexible - resources, locals and outputs together.
  • Validated - identifier names are checked before output.
  • Fast - scaffold a module without a terminal.
  • Reusable - DRY values via locals and expose via outputs.
  • Consistent - a shared baseline shape for every module.
  • Safe by default - sensitive outputs are flagged where needed.
  • Private - everything runs in the browser.

Frequently Asked Questions

What does this tool generate?
It writes a main.tf file containing resource blocks (with attributes), an optional locals block and output blocks.
Which providers are supported?
Any. Type the resource type such as aws_instance, google_compute_instance or azurerm_resource_group.
How are attributes added?
Each resource has its own attribute rows with a key, value and type (string, number, bool or raw).
Does this connect to a cloud?
No. Everything is assembled in your browser and nothing is uploaded.
Can I download it?
Yes. Copy the HCL, download main.tf, or print it.