Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ One parser. One IR. Zero lock-in.
[![Status](https://img.shields.io/badge/status-alpha-fbbf24?style=for-the-badge)](#-timeline)
[![PRs](https://img.shields.io/badge/PRs-welcome-34d399?style=for-the-badge)](#-contributing)

[![Terraform](https://img.shields.io/badge/Terraform-HCL2-7B42BC?style=flat-square&logo=terraform&logoColor=white)](https://developer.hashicorp.com/terraform/language)
[![Terraform](https://img.shields.io/badge/Terraform-1.0_%E2%80%93_1.17-7B42BC?style=flat-square&logo=terraform&logoColor=white)](docs/TERRAFORM-VERSIONS.md)
[![AWS CDK](https://img.shields.io/badge/AWS_CDK-TypeScript-FF9900?style=flat-square&logo=amazonaws&logoColor=white)](https://aws.amazon.com/cdk/)
[![Pulumi](https://img.shields.io/badge/Pulumi-TypeScript-8A3391?style=flat-square&logo=pulumi&logoColor=white)](https://www.pulumi.com/)
[![IR](https://img.shields.io/badge/IR-schema_0.1-818cf8?style=flat-square)](docs/ARCHITECTURE.md#the-ir-contract)
[![IR](https://img.shields.io/badge/IR-schema_0.2-818cf8?style=flat-square)](docs/IR.md)
[![Made with Go](https://img.shields.io/badge/made_with-Go-00ADD8?style=flat-square&logo=go&logoColor=white)](https://go.dev)

<br/>
Expand All @@ -27,7 +27,7 @@ One parser. One IR. Zero lock-in.

<br/>

[🚀 Playground](playground/) · [📦 Quick Start](#-quick-start) · [🗺️ Roadmap](docs/ROADMAP.md) · [🧠 How It Works](#-how-it-works) · [🧱 Architecture](docs/ARCHITECTURE.md) · [🧪 Conformance](docs/CONFORMANCE.md) · [🤝 Contribute](CONTRIBUTING.md)
[🚀 Playground](playground/) · [📦 Quick Start](#-quick-start) · [🗺️ Roadmap](docs/ROADMAP.md) · [🧠 How It Works](#-how-it-works) · [🧱 Architecture](docs/ARCHITECTURE.md) · [📄 IR Reference](docs/IR.md) · [🧭 Version Support](docs/TERRAFORM-VERSIONS.md) · [🧪 Conformance](docs/CONFORMANCE.md) · [🤝 Contribute](CONTRIBUTING.md)

</div>

Expand Down Expand Up @@ -160,14 +160,19 @@ Open `http://localhost:8080`, paste Terraform, get TypeScript. **No backend.**

## 🧠 How It Works

Terraform **1.0–1.17** configuration parses in both syntaxes; conversion covers
a documented subset of it. Anything outside that subset is preserved in the IR
and reported as a coded warning, never silently dropped.

```text
┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Terraform │ │ Universal │ │ Dependency │ │ Native TS │
│ HCL │ ──▶ │ IR │ ──▶ │ DAG │ ──▶ │ emitters │
│ .tf / .tfvars│ │ JSON-shaped │ │ topo-sorted │ │ CDK / Pulumi │
│.tf / .tf.json│ │ JSON-shaped │ │ topo-sorted │ │ CDK / Pulumi │
└──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘
▲ ▲ ▲ ▲
hcl/v2 parser resources+vars Kahn's algorithm JSON mappings
HCL + JSON + preserved blocks
```

<table>
Expand All @@ -179,7 +184,7 @@ Open `http://localhost:8080`, paste Terraform, get TypeScript. **No backend.**
<tr>
<td><b>Parse</b></td>
<td><a href="pkg/parsers/hcl/"><code>pkg/parsers/hcl</code></a></td>
<td>Reads <code>resource</code>, <code>data</code>, <code>variable</code>, <code>locals</code>, <code>output</code>, <code>module</code>, <code>provider</code> blocks into the IR.</td>
<td>Reads native HCL and JSON (<code>.tf</code> and <code>.tf.json</code>) for every Terraform 1.0–1.17 top-level block. Constructs without a target mapping are preserved, never dropped — see <a href="docs/TERRAFORM-VERSIONS.md">version support</a>.</td>
</tr>
<tr>
<td><b>Resolve</b></td>
Expand Down Expand Up @@ -302,7 +307,7 @@ Add it to [`pkg/mappings/aws.json`](pkg/mappings/aws.json), rebuild, done.

```json
{
"version": "0.1",
"version": "0.2",
"resources": [
{
"id": "aws_vpc.main",
Expand All @@ -311,10 +316,14 @@ Add it to [`pkg/mappings/aws.json`](pkg/mappings/aws.json), rebuild, done.
"attributes": { "cidr_block": { "kind": "string", "literal": "10.0.0.0/16" } }
}
],
"edges": [{ "from": "aws_vpc.main", "to": "aws_subnet.public", "kind": "reference" }]
"min_version": "1.0.0",
"edges": [{ "from": "aws_subnet.public", "to": "aws_vpc.main", "kind": "reference" }]
}
```

`from` depends on `to`. Every field, value kind and guarantee is documented in
[docs/IR.md](docs/IR.md).

</details>

---
Expand Down Expand Up @@ -356,7 +365,7 @@ See [docs/CONFORMANCE.md](docs/CONFORMANCE.md) for the L0–L4 oracle design and
| Milestone | Date | Highlights | State |
|:--|:--|:--|:--:|
| **Foundation** | Oct 2026 | HCL parser · IR · DAG · CDK + Pulumi emitters · WASM playground | ✅ |
| **v0.1 Public Alpha** | Nov 2026 | Docs · tests · CI · GitHub Pages playground | 🚧 |
| **v0.1 Public Alpha** | Nov 2026 | Docs incl. [IR](docs/IR.md) & [version](docs/TERRAFORM-VERSIONS.md) references · tests · CI · GitHub Pages playground | 🚧 |
| **v0.2 Depth** | Dec 2026 | Data sources · `locals` · richer L2 mappings | ⏳ |
| **v0.3 Scale** | Q1 2027 | Modules · `count` / `for_each` · multi-file imports | ⏳ |
| **v1.0 Stable** | Q2 2027 | CloudFormation + Terraform backends · plugin API | 🎯 |
Expand All @@ -383,11 +392,13 @@ OpenIaC/
├── internal/conformance/ Collector and conformance layers
├── pkg/
│ ├── ir/ Universal graph + topological sort
│ ├── parsers/hcl/ HCL2 → IR
│ ├── parsers/hcl/ HCL2 and JSON → IR
│ ├── tfversion/ Terraform language version detection
│ ├── mappings/ Data-driven aws.json registry
│ ├── emitutil/ Naming, rewriting, rendering
│ ├── emitters/ aws-cdk/ + pulumi/
│ ├── emitters/ aws-cdk/ + pulumi/ (+ shared warnings)
│ └── engine/ Orchestration
├── docs/ Architecture, IR, versions, conformance, roadmap
├── wasm/ js/wasm entry point
├── playground/ Monaco + WASM UI
├── examples/ Sample Terraform modules
Expand Down
39 changes: 28 additions & 11 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ target-agnostic graph, then renders that graph as TypeScript for AWS CDK or
Pulumi.

```text
.tf files
.tf / .tf.json
│
▼
┌────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐
Expand All @@ -23,8 +23,9 @@ writing one package, not a new frontend.

| Package | Responsibility |
|:--|:--|
| [`pkg/parsers/hcl`](../pkg/parsers/hcl/) | Reads native HCL syntax into the IR. The only package that knows Terraform exists. |
| [`pkg/ir`](../pkg/ir/) | Graph types, edge bookkeeping, deterministic topological order, cycle reporting. |
| [`pkg/parsers/hcl`](../pkg/parsers/hcl/) | Reads native HCL and JSON (`.tf` and `.tf.json`) into the IR. The only package that knows Terraform exists. |
| [`pkg/ir`](../pkg/ir/) | Graph types, edge bookkeeping, deterministic topological order, cycle reporting. Contract documented in [IR.md](IR.md). |
| [`pkg/tfversion`](../pkg/tfversion/) | Maps detected language features to `min_version`; parses `required_version` constraints. |
| [`pkg/mappings`](../pkg/mappings/) | Embedded JSON registry describing target constructs per resource type. |
| [`pkg/emitutil`](../pkg/emitutil/) | Naming, reference rewriting, value/template rendering shared by emitters. |
| [`pkg/emitters/awscdk`](../pkg/emitters/awscdk/) | `aws-cdk-lib` TypeScript, L1 and L2 constructs. |
Expand All @@ -37,19 +38,32 @@ writing one package, not a new frontend.
The IR is deliberately flat. It has no loops, conditionals or expressions the
emitter must evaluate — those are either resolved or reported as a warning.

Schema `0.2` is additive over `0.1`. The full reference — every field, value
kind, guarantee and the extension policy — is in [IR.md](IR.md).

```go
type Graph struct {
Version string
Resources []*Resource // managed resources and data sources
Variables []*Variable
Locals []*Local
Outputs []*Output
Modules []*Module
Providers []*Provider
Edges []Edge
Version string
Terraform *Terraform // merged terraform block settings
Resources []*Resource // managed resources and data sources
Variables []*Variable
Locals []*Local
Outputs []*Output
Modules []*Module
Providers []*Provider
Preserved []Block // moved, import, removed, check, ephemeral, action, unknown
Features []string // detected Terraform language features
MinVersion string // oldest Terraform release that accepts the input
Edges []Edge
}
```

`Preserved` is how the parser accepts the whole Terraform 1.x language without a
typed node per construct: anything OpenIaC cannot convert is kept in the graph so
an emitter can warn about it, and never enters `Resources` (both emitters treat
every entry there as a managed resource). See
[TERRAFORM-VERSIONS.md](TERRAFORM-VERSIONS.md).

### Nodes

A `Resource.ID` is the Terraform address:
Expand Down Expand Up @@ -169,6 +183,9 @@ To add a target:
2. Implement `Emit`: call `graph.Order()`, build identifiers, construct one
`RefRewriter`, render each node.
3. Collect every unsupported construct in `emitters.Warnings` — never drop it.
Call `emitters.WarnUnsupported(graph, warnings)` once, right after creating
the collector, so preserved blocks, unconverted `terraform` settings and
conditions are reported with their stable `W_*` codes.
4. Register the target in `engine.NewEmitter` and `engine.ParseTargets`.

## Determinism
Expand Down
17 changes: 17 additions & 0 deletions docs/CONFORMANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,23 @@ One pinned image with:
| `W_PROVIDER` | Non-AWS or aliased provider not converted |
| `W_FUNCTION` | Unsupported HCL function |
| `W_HEREDOC` | Heredoc left unchanged |
| `W_PRESERVED_BLOCK` | A top-level block has no target mapping and was preserved (`moved`, `import`, `removed`, `check`, `ephemeral`, `action`, or an unknown type) |
| `W_TERRAFORM_BACKEND` | `terraform.backend` was not converted |
| `W_TERRAFORM_CLOUD` | `terraform.cloud` was not converted |
| `W_TERRAFORM_PROVIDER_META` | `terraform.provider_meta` was not converted |
| `W_CONDITION` | A `precondition` / `postcondition` was not converted |
| `W_VARIABLE_VALIDATION` | A variable `validation` block was not converted |
| `W_UNSUPPORTED_FIELD` | A typed node carries an attribute or nested block the IR does not model |

Warnings added from schema `0.2` onward are emitted as `CODE: message`, with
`file:line` taken from the IR's provenance so the text is portable. Codes are
grouped and sorted where the same construct repeats, and `Warnings` dedupes
identical text, so a fixture can assert an exact message.

`W_PRESERVED_BLOCK` is the code that keeps `silent_drops` at zero for the
Terraform 1.x language: a construct OpenIaC cannot convert always produces at
least one warning. `required_version` alone never warns — it is metadata about
the input, not a conversion gap.

Warning codes must be stable, documented and asserted by fixtures. Codes may be
added; changing or removing one is a breaking change.
Expand Down
Loading
Loading