All Tools View Categories About Contact Privacy

Terraform Data Source Generator

Build a valid Terraform data source block (HCL) for any provider data source.

Runs entirely in your browser - nothing is uploaded and no cloud connection is made.
Your generated data source block will appear here.

About Terraform Data Source Generator

The Terraform Data Source Generator builds one complete data block for any provider data source, including optional provider aliases, count or for_each repetition, typed attributes, and nested blocks. Data sources are how Terraform reads existing infrastructure or external information, and a single misplaced argument can break a plan. This generator removes the guesswork by assembling valid HCL for you.

You choose the data source type and a name, then optionally add a provider alias to read from a non-default configuration, a for_each to produce many blocks from a map or set, typed attributes, and nested blocks such as filter or ingress. The output respects Terraform quoting rules so strings, numbers, booleans, and raw expressions are serialized correctly. Everything runs locally in your browser; no provider is called and nothing is uploaded, so you can prototype data sources safely before touching real infrastructure. It is equally useful for experienced engineers standardizing modules and for newcomers learning how data sources are shaped.

Because the tool never contacts a provider, it is a safe sandbox for experimenting with data source arguments before you run a real plan. You can try different filters, nested blocks, and provider aliases, confirm the HCL shape, and only then paste the block into your project. Teams also use it to keep data sources consistent across many modules, avoiding the small formatting differences that appear when everyone hand edits configuration files. The generator is the fastest way to move from a provider documentation page to working, valid HCL.

Features

  • Any data source - aws_ami, google_compute_image, azurerm_resource_group, or your own custom type.
  • Provider alias - read data with a non-default provider configuration.
  • for_each support - emit one block per entry in a map or set.
  • Typed attributes - string, number, boolean, or raw so values serialize correctly.
  • Nested blocks - add blocks such as filter with their own typed attributes.
  • Live preview - the HCL appears immediately in a copy-ready panel.
  • Client-side validation - names and identifiers are checked before output.
  • Copy, download and print - export as data.tf, to the clipboard, or to paper.
  • No dependencies - runs offline in any modern browser.
  • Private by design - your configuration never leaves the page.
  • Consistent output - every block follows the same canonical layout and indentation.
  • Reusable - load the sample once, then adapt it for each environment you manage.

How to Use

  1. Open the form and enter the data source type, for example aws_ami or azurerm_resource_group.
  2. Name the block with a valid Terraform identifier; the tool validates it for you.
  3. Optionally add a provider alias when you read from a secondary provider configuration.
  4. Add attributes using the Add attribute button and pick the right type for each value.
  5. Add nested blocks with the Add block button, giving each a type and its own attributes.
  6. Generate the HCL and review it in the preview panel on the right.
  7. Export with Copy, Download data.tf, or Print.
  8. Start over with Clear, or use Load sample for a realistic starting point.
  9. Review the validation messages if anything is missing, fix the highlighted fields, and regenerate until the output is clean.

Examples

Example 1 - filtered AMI. Type aws_ami, name it web, set most_recent = true, and add a nested filter block of type name with values ["18.04","20.04"] as a raw list. The result finds the newest Ubuntu image matching those versions.

Example 2 - provider alias. Add an alias such as alt so the data source reads from a second provider configuration, which is common when managing multiple regions from one project. The alias is emitted as a provider argument inside the data block.

Example 3 - for_each. Provide a for_each expression such as var.ids and the tool includes it on the data block, which is handy when you want to read one data item per entry in a collection within a larger module.

Benefits

  • Correct schema - properly quoted, nested, typed HCL every time.
  • Faster authoring - skip hand formatting and quoting mistakes.
  • Flexible - aliases, for_each, and nested blocks included.
  • Learning aid - see how arguments map to HCL output.
  • Portable - copy, download, or print wherever you work.
  • Private - nothing is uploaded or sent anywhere.
  • Safe sandbox - experiment with arguments before running a real plan.

Frequently Asked Questions

What does this tool generate?
One data block for any provider data source, with a type, name, optional provider alias, count/for_each, attributes and nested blocks.
Which data sources are supported?
Any. Type the data source type such as aws_ami, google_compute_image or azurerm_resource_group.
What is the provider alias for?
Use it to read data with a non-default provider configuration.
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 data.tf, or print it.