Draft · 0.6.0

A `0.x` draft in production use by adopters: pin the exact draft and runtime release; no compatibility guarantee between drafts.

Normative for the reader class on terraform-file-v1.0.0; reading 1.0.0 released View current source

The terraform-file reading

On this page

Status

This document is a companion document of the Judgment Pack specification. It defines the reading of a Terraform plan or state, as terraform show -json writes it: the checks a reader holds the file's bytes to, the removal of every value marked sensitive, the selection of resources, the value acquired and its acquisition record, and the batch a reference runtime may write from that value.

This text is the terraform-file reading 1.0.0, status released. The version is this document's own: it is neither a Core specVersion nor a dialect version, and no pack declares it. The companion is released on its own scoped tag, terraform-file-v<major>.<minor>.<patch>, beside Core and independent of specVersion; its first release is terraform-file-v1.0.0 (§10). A text no terraform-file tag released is normative for nothing, and no conformance claim may cite it. This text, released on terraform-file-v1.0.0, is normative for the conformance class of §12, and for nothing else. Publication beside a Core release, on the site or in a Core bundle, releases nothing.

Its design record is RFC 0038, accepted on 2026-11-16, which is informative. The readings this text settles that RFC 0038 left open, and why, are recorded in the amendments of 2026-11-17 to the dialect's design record, RFC 0018. The maintainer accepted RFC 0038 on one review round by a model from the drafting vendor, with the different-vendor review of the interim review regime waived, as its Acceptance section says. That is a same-vendor review, not a cross-vendor claim. Where this text and the record differ, this text governs; §13 lists what is open.

The dialect names the kind whose file this text reads: a terraform-file source of dialect version 3, which is proposed, declares its file by the members of §2 (dialect.md §4.5). Dialect version 3 and later Core releases cite this text rather than carry it. Core is unchanged by this document, and so is every form of the dialect.

Version 1.0.0 is released, on terraform-file-v1.0.0, and not yet stable:

  • Its vectors are published. The machine-readable code list and format table, and the hand-written vectors, under conformance/terraform-file/1.0.0/ (§§11, 12), are in that release's own bundle, and its release record names each file's digest (§10). No Core bundle carries them, and the site does not serve them.
  • Two readers exist. The reference runtime reads the file, deposed objects (§3, step 4) included (v0.49.0), and where this text settles what RFC 0038 left open, it says what that reader does. A second reader, written from this text alone, is in this repository (tools/terraform_file_reader.py) and gives every vector's expected result; it was written by a model from the drafting vendor, a same-vendor reader and not a cross-vendor claim. The stable bar (§12) is two independently written readers agreeing on every vector, the second from a different vendor; this same-vendor reader does not meet it, so the reading is not yet stable.

The key words MUST, MUST NOT, REQUIRED, SHOULD, SHOULD NOT and MAY have their BCP 14 meanings only in capitals.

1. Terms

  • A declaration (§2) says which output of terraform show -json a file is, which of its resources to select, and the largest file read. A terraform-file source of the dialect is one (dialect.md §4.5); a tool may take one by its own options, as the reference runtime's batch does (§8).
  • A reader reads a file under a declaration by the steps of §3, and gives either the acquired value (§6) with its acquisition record (§7), or a refusal with one code of §9.
  • An integer of a declaration written in JSON is an integer as the dialect defines one (dialect.md §1): its literal has no fraction and no exponent, so 1.0 and 1e2 are not integers.
  • A pointer is an RFC 6901 JSON Pointer. A value's canonical form is its RFC 8785 form.
  • Code-point order compares two strings by their Unicode code points, first difference first.
  • A file's sha256 is the SHA-256 digest of all its bytes, written as 64 lower-case hexadecimal digits with no prefix.

2. The declaration

A declaration has exactly document (plan or state: which output of terraform show -json the file is), select (§5) and maxBytes (optional, an integer from 1 to 268435456, default 67108864). It names no path: the caller supplies the file, and binds its path at evaluation time.

A declaration not of this form, actions on a state and a malformed select among them (§5), is malformed, and no file is read under it. What holds the declaration refuses it: dialect.md §4.5 says how a dialect document that holds one is refused.

3. Reading the file

A reader takes these steps in order. The first failure refuses the acquisition with its code (§9), and later steps do not run. A diagnostic carries its code, the file's sha256 and its size, and a message: a fixed text for its code, which holds nothing read from the file. It carries nothing else: no value, member name, pointer or position. The wording of a message is the reader's own, and not part of this text. The one exception is a stream's TF-SIZE (step 1), which carries its code and its message, and neither the sha256 nor the size.

  1. The sha256 of the whole file and its length are recorded. A file longer than maxBytes is TF-SIZE, unparsed. An input read as a stream, such as standard input, is read to at most maxBytes and one byte more: a longer stream is TF-SIZE, unparsed, and its diagnostic carries the code and a fixed message that the input was a stream, with no sha256 and no size, since its whole length is never read. A stream within maxBytes has its sha256 and length recorded as a file's are.
  2. The bytes are UTF-8 with no byte-order mark and no lone surrogate escape, one JSON value with only white space after it, nested at most 128 deep (the top-level value at depth 1), with no duplicate member name; otherwise TF-JSON. Numbers are kept as their decimal text.
  3. The top-level value is an object whose format_version is a string in the accepted table for document (§4); otherwise TF-FORMAT.
  4. A plan has planned_values, an object, and resource_changes, when present, an array (absent reads as empty). A state has neither planned_values nor resource_changes, and values, when present, is an object (absent reads as no resources). In a state, values.root_module, when present, is a module (absent reads as no resources). A module is an object, which needs no address. Its resources, when present, is an array of objects, and its child_modules, when present, is an array of modules; either one, when absent, reads as empty. Otherwise TF-DOCUMENT. Modules nest with no bound but step 2's depth. Each resource of the read section (step 5), an item of resource_changes or of a module's resources, has address, type, name, mode and provider_name, each a string, which may be empty. Its index is optional, and when present a string or a number. A state's resource may lack values. None of these is checked against another: mode is not restricted when read, and a resource whose mode is not the one select names is read and not selected (§5); an address is not checked against its type or name. Any other resource is TF-DOCUMENT. A resource of the read section that is a deposed object, one an apply replaced but has not yet destroyed, has a deposed key, deposed in a plan and deposed_key in a state, which is a non-empty string. A resource's id is its address, or, with a deposed key, its address, a space, deposed, a space and the key. A deposed key of another type, an empty one, or two resources of the read section with one id, is TF-DOCUMENT. In a plan, each item of resource_changes is an object whose change is an object, with actions an array of strings, and before and after optional; any other item is TF-DOCUMENT. A resource change's change.after_unknown, when present, has a mirror's form: true, false, or an object or array of mirrors. Any other after_unknown, null included, is TF-DOCUMENT.
  5. The read section is resource_changes for a plan, and every resource under values.root_module and its child_modules, recursively, for a state. Every resource in it, selected or not, carries its sensitivity mirror (change.before_sensitive and change.after_sensitive, or sensitive_values): true, false, or an object or array of mirrors, Terraform writing the value's shape (step 6 reads any other). A missing mirror, or one with a string, number or null at any position, is TF-SENSITIVITY.
  6. In each value of the read section, every position whose mirror is true is removed with all it holds: an object member is removed; an array element is never removed alone, and the array that holds it is removed instead, up to the nearest object member. A mirror position absent from the value is ignored. Nothing replaces a removed value. removedSensitive counts the object members removed, and a values, before or after removed whole counts one, as an object member of its resource would. A removal counts one however much it holds: an object member inside a removed value, or inside an array removed up to the nearest object member, is not counted apart from it. after_unknown pointers at or below a removed position are dropped. Terraform leaves a value unknown at plan time out of after, so after_sensitive is read along after_unknown as well: a pointer that ends at, or passes through, a position that after_sensitive marks true and after lacks is cut at that position, so no member name below it is carried. The pointers cut at one position are one pointer, and none when after_unknown marks nothing true at or below it. Mirror and value positions are matched as RFC 6901 tokens are, whatever their shapes: a mirror member names the value's member of that name, or, over an array, the element its name indexes (0, or a digit 1 to 9 and further digits, less than the array's length), and any other name names nothing; a mirror array's element k names an array's element k, or an object's member named k in decimal. A mirror object or array that marks any position true, at any depth, over a string, number, boolean or null, removes that value; an empty mirror object or array removes nothing.
  7. Selection (§5), then the acquired value (§6).

A reader never reads configuration, variables, relevant_attributes, checks, prior_state, planned_values (beyond step 4), output_changes or outputs.

4. Accepted formats

This text keeps a table of accepted format_version values per document, with its own release number; each accepted format_version of each document is backed by its own set of vectors, written by hand to the shape that Terraform's documentation of its JSON output format gives for that version, with no Terraform run and no recorded output. A version not in a reader's claimed table, including a newer minor of a listed major, is TF-FORMAT. The table grows by a patch release and never shrinks within a dialect version. The first table (RFC 0038, Unresolved question 2, resolved) is the one the reference runtime's reader held under the provisional name proposed-1, and now holds as release 1.0.0:

document Accepted format_version
plan 1.0, 1.1 and 1.2
state 1.0

The table's release number is a semantic version, and each newly accepted row is a patch release. The first table's release is 1.0.0, which the acquisition record's formatTable carries (§7).

5. Selection

select has types, a non-empty array of at most 64 distinct resource type names, each a non-empty string with no other bound on its length or its characters; mode, managed (default) or data, compared with each resource's mode, which is not restricted when read (§3, step 4), so a resource of any other mode is read and never selected; address, optional, a pattern of at most 512 characters that matches the whole address, in which * matches any run of characters other than ., [ and ] and every other character matches itself; actions, optional and plan only, an array of names from create, update, delete, read and no-op, keeping changes whose change.actions include one; and max, an integer from 1 to 10000 (default 1000), past which the acquisition is TF-SELECT-BOUND. A name may repeat in actions, which is read as the set of its names, so neither a repeat nor the order changes what is kept. An empty actions keeps no change, and so selects nothing: it is not the absence of the filter. An empty types, an empty or repeated type name, more than 64 type names, an actions name outside the five, actions on a state, or another malformed select, makes the declaration malformed (§2). Child-module resources are included with their full address; selecting nothing gives an empty array.

6. The acquired value

The acquired value is an array sorted by id (§3, step 4) in code-point order, one object per selected resource: for a state, {"address", "type", "name", "mode", "providerName", "index"?, "deposed"?, "values"?}, with deposed the deposed key, present only for a deposed object; for a plan, the same with "actions", "before"?, "after"? and "afterUnknown" (the sorted pointers, in after, of values known only after apply) in place of "values"?. Each pointer of afterUnknown is the string of its RFC 6901 form, ~0 and ~1 escapes included, and the pointers are sorted in code-point order of those strings. A values, before or after that step 6 of §3 removes whole is absent from the resource's object. Numbers become decimal strings in the registry companion's normal form (spec/registry.md §10.1), with 0 for every zero; one whose normal form would be longer than 64 characters is TF-NUMBER. The value is then bounded by L, the lesser of 268435456 and sixteen times the file's length in bytes. It is TF-VALUE-LIMIT, after TF-SELECT-BOUND and TF-NUMBER, when its canonical form (RFC 8785) is longer than L bytes, or when the afterUnknown pointers of one selected plan resource, each charged the length in bytes of its RFC 6901 form and eight bytes more, total more than L less the bytes of the canonical form that come before that resource's object (the array's opening [, the objects of the resources before it, and the comma after each of them); so a reader can refuse before it holds the value or the pointers. Numbers in normal form grow at most about 13.4 times (an array of 1e63) and strings do not grow, so pointers that repeat a long member name are what reach the multiple.

7. The acquisition record

The acquisition record is {"kind": "terraform-file", "document", "formatVersion", "formatTable", "sha256", "bytes", "removedSensitive", "selected"}, with no path. Its formatTable is the release of the accepted table the reader read the file by (§4): 1.0.0 for the first table.

8. The batch

A reference runtime may also write the acquired value as an evaluation batch, one line per selected resource with the resource's id (§3, step 4) and facts {"terraform": {"document", "formatVersion", "sha256"}, "resource": …}; that batch is a product format, not a dialect member. Each line's id is 1 to 256 bytes of UTF-8, the bound the reference runtime's batch evaluation holds an item's id to. A selected resource whose id is outside it refuses the whole run, before any line is written, with FACTS-ID-LIMIT, the registry companion's code of a batch line's id bound (spec/registry.md §10.2), and neither a dialect code nor one of §9's: every selected resource is checked for it before any facts document is held to the registry companion's facts bound (FACTS-DOCUMENT-LIMIT, spec/registry.md §10.1). An id is outside the bound when it is empty or longer than 256 bytes. Then every selected resource's facts document is held to the facts bound, and one over it refuses the whole run in the same way, before any line is written, with FACTS-DOCUMENT-LIMIT. Either refusal covers the whole run: no line is written, and a batch is written whole or not at all. The diagnostic of each carries what a refusal of the reading carries (§3), the code, the file's sha256, its size and the code's message, and never the id. The reference runtime's batch tool gives either refusal as exit status 2 with nothing on standard output, and writes its diagnostic to standard error as one RFC 8785 canonical object, of the members bytes, code, message and sha256, and a line feed. The tool may refuse an empty actions on its command line, since a command line has no other way to say that nothing is to be selected; that is a rule of the tool's flags, not of the reading, in which an empty actions selects nothing (§5).

9. Diagnostic codes

The list is closed: a refusal of the reading carries exactly one of these eight codes, the code of the step that refused it (§3), which states the rule; a row only names it. Each code's severity is error, and each code's status in 1.0.0 is active. The machine-readable list is conformance/terraform-file/1.0.0/codes.json (§11); where the two differ, this text governs. FACTS-ID-LIMIT and FACTS-DOCUMENT-LIMIT, which the batch reports (§8), are the registry companion's codes (spec/registry.md §12), and not this list's.

Code Severity Step Raised when
TF-SIZE error 1 the file, or an input read as a stream, is longer than maxBytes
TF-JSON error 2 the bytes are not one JSON value in UTF-8 with no byte-order mark, no lone surrogate escape, only white space after it, nesting at most 128 deep and no duplicate member name
TF-FORMAT error 3 the top-level value is not an object whose format_version is a string in the accepted table for document
TF-DOCUMENT error 4 the file is not of its document's shape, a resource change, its after_unknown or a deposed key is not of its form, or two resources of the read section have one id
TF-SENSITIVITY error 5 a resource of the read section has no sensitivity mirror, or one with a string, number or null at any position
TF-SELECT-BOUND error 7 (§5) more resources are selected than max
TF-NUMBER error 7 (§6) a number of the acquired value has a normal form longer than 64 characters
TF-VALUE-LIMIT error 7 (§6) the acquired value's canonical form, or one selected plan resource's afterUnknown pointers as charged, are over L

10. Versioning and stability

The companion is released on the scoped tag terraform-file-v<major>.<minor>.<patch>. The first release is terraform-file-v1.0.0, at status released: it is released, and not stable, and it carries the first table, release 1.0.0 (§4). A tag's number is the table release it carries, and each later tag is the next patch: one that adds a row to the table, and one, an erratum, that corrects this text, the lists or the vectors and adds no row (VERSIONING.md).

A tag names, in its release record releases/<tag>.json, the reading 1.0.0; the SHA-256 of this text and of the vectors' README; the format table with its digest, its release, its rows and the rows that release adds, none for an erratum; the code list with its digest and its codes; the vectors' manifest with its digest, the id of every vector and the digest of every file under conformance/terraform-file/1.0.0/; and the SHA-256 of the second reader. Its bundle, judgment-pack-terraform-file-<version>, publishes this text, the code list, the format table, the declarations and the vectors with their README, the checks that hold the vectors to this text with the second reader they run, and the record and the notes. A Core bundle carries this text and none of those files. No code, table row or vector that a release names is dropped by a later release of the same reading, whose bytes may change and whose own record pins them. No stability promise is made before the first stable release, which needs two readers agreeing on every vector (§12).

Dialect version 3, which is proposed, and later Core releases cite this text rather than carry it.

11. Machine-readable form and vectors

The machine-readable form and the vectors are under conformance/terraform-file/1.0.0/, released with this text: the code list of §9 as codes.json, with each code's severity, status and step; the accepted table of §4 as formats.json, with its release; and the vectors of §12, with a manifest that names, for each vector, the table release that added its row. Every input is synthetic. Where a file and this text differ, this text governs.

12. Conformance

Class Sections Vectors
Reader §§2–7 and §9, and §8 for a reader that writes the batch conformance/terraform-file/1.0.0/, released

A claim names the exact release, the table release it implements, and its complete vectors. A reader is held only to the vectors of the table releases it claims: a file whose format_version is in a later table than the reader's is TF-FORMAT for that reader, and that is the expected result for its claim (RFC 0038 §3). A class without vectors is defined, and not claimable. The stable bar is two independently written readers agreeing on every vector.

Vectors. The vectors, each written by hand as §4 says, are those RFC 0038's Conformance section lists, with these besides, each with one expected result:

  • a stream of maxBytes bytes (accepted, with its sha256 and size), and a stream of one byte more (TF-SIZE, with no sha256 and no size), beside the file row of maxBytes and one byte more, which stays a file row;
  • a plan whose afterUnknown pointers repeat a long member name past sixteen times the file's length (TF-VALUE-LIMIT); a plan whose pointers fit that bound as their canonical form but not with eight bytes charged to each (TF-VALUE-LIMIT), beside one that fits both; and a file of 1e63 numbers, whose value grows about 13.4 times (accepted);
  • mirrors whose shape differs from the value, which Terraform does not write, since it writes the mirror in the value's shape: a mirror object over an array, marking an element by its index and naming a member that is not an index; a mirror array over an object, marking the member 0; a mirror object over a string, marking a position below it (removed); and an empty mirror object over a number (kept);
  • for the reference runtime's batch, a selected resource whose address is 256 bytes (one line, with that id), and one of 257 bytes beside a resource whose facts document is over the facts bound (FACTS-ID-LIMIT, and no line);
  • deposed objects: a plan whose replacement left a deposed object to delete, and a state holding a deposed object beside its current one, each carried with deposed and sorted after the current object; two resources of one id, and a deposed key that is a number, neither of which Terraform writes (each TF-DOCUMENT); and, for the batch, a deposed object whose id passes 256 bytes while its address does not (FACTS-ID-LIMIT).

The default max of §5, 1000, has no vector: its pair would hold a thousand selected resources and their value, so the vectors hold max only as a declaration gives it.

13. What is open

  • A refusal's source outcome. How a refusal of §3's steps maps to a source outcome (dialect.md §9.2) is not stated here: a refusal's source outcome is defined when dialect version 3 opens. RFC 0038 records a proposal, open, as its Unresolved question 6.
  • Outside this release: outputs (RFC 0038, Unresolved question 4); a kind for another tool that writes the same JSON (Unresolved question 3); format_version values 0.x, which no table lists; and the kind's place in a dialect document, which waits on dialect version 3 (dialect.md §4.5).
  • Review regime. The different-vendor review was waived for the record.