DIALECT_IDconstconst DIALECT_ID: "opentofu"The id of the dialect.
The dialect of Archon for cloud resources with OpenTofu: what it guarantees (as data), how it renders an order of cloud-resource requirements to one JSON configuration (OpenTofu's JSON syntax), and the steps that carry the plan out. It renders and says what to run; it runs nothing, and it needs no network.
What makes it safe to hand to a pipeline: every provider the order uses is named with an exact version (a provider the options do not name is refused, so nothing is fetched that nobody pinned); no credential is ever in the render, because a requirement or a provider setting that holds one is refused (the provider reads its credentials from the environment of the run, as every cloud's own tooling does); the state is kept outside the repository (a backend the options name, or a file in a folder the options name that is not in the render's folder), so the state, which holds the secrets of what it made, is never committed; the arguments that run code (provisioner, connection) are refused; and the steps plan to a saved plan and apply exactly that plan, so that what was shown is what is done (and the plan is checked against the order first: checkPlan).
import { opentofu, KINDS_CARRIED } from "./dialect.ts";
KINDS_CARRIED; // ["cloud-resource"]DIALECT_IDconstconst DIALECT_ID: "opentofu"The id of the dialect.
PINNED_VERSIONconstno test imports itconst PINNED_VERSION: "1.9.0"The version of OpenTofu the dialect pins. A fleet that pins another passes it.
KINDS_CARRIEDconstconst KINDS_CARRIED: readonly ["cloud-resource"]The kinds of resource the dialect carries out.
ProviderPintypeno test imports ittype ProviderPin = {
/** Where it comes from, as the registry names it: `hashicorp/aws`. */
readonly source: string;
/** Its exact version: a range is not a pin. */
readonly version: string;
/** Its settings (a region, a profile name, an endpoint): never a credential. */
readonly config?: { readonly [key: string]: JsonValue };
};A provider the order may use, pinned.
OpenTofuOptionstypetype OpenTofuOptions = {
/** The providers the order may use, by the local name the requirements give (`aws`). */
re… (756 characters)type OpenTofuOptions = {
/** The providers the order may use, by the local name the requirements give (`aws`). */
readonly providers: { readonly [name: string]: ProviderPin };
/** The folder the state, the saved plan and the provider data are kept in: absolute, and outside the render. */
readonly stateDir: string;
/** Where the state lives where it is not a file of `stateDir`: a backend and its settings (never a credential). */
readonly backend?: { readonly type: string; readonly config: { readonly [key: string]: JsonValue } };
/** The version of OpenTofu the run must have. */
readonly version?: string;
/** The folder, below the working folder, the render is written in; `.archon` by default. */
readonly renderRoot?: string;
};What the dialect is made with.
optionProblemsfunctionfunction optionProblems(o: OpenTofuOptions): readonly string[]The problems of the options, or none.
resourcesOffunctionfunction resourcesOf(order: Order, o: OpenTofuOptions): Result<readonly Resource[], readonly string[]>The resources of an order, or every reason it cannot be rendered.
configurationOffunctionfunction configurationOf(resources: readonly Resource[], o: OpenTofuOptions): ObjThe configuration of an order, in OpenTofu's JSON syntax, as an object whose keys are in order.
opentofufunctionfunction opentofu(options: OpenTofuOptions): DialectThe dialect, as the port of Archon takes it.
PlannedChangetypeno test imports ittype PlannedChange = { readonly address: string; readonly actions: readonly string[] };What OpenTofu would do to one resource.
changesOffunctionfunction changesOf(showJson: string): Result<readonly PlannedChange[], string>The changes of tofu show -json <plan>, or why the text is not that.
planDigestfunctionfunction planDigest(changes: readonly PlannedChange[]): Promise<string>The digest of what a plan would do: the addresses and the actions, and nothing of the values (a plan holds the secrets of what it makes). It is the hash an approval names.
checkPlanfunctionfunction checkPlan(order: Order, changes: readonly PlannedChange[]): readonly string[]What a plan does that the order did not ask for: a resource it would destroy or replace that no requirement asks to remove or replace, and a change to a resource no requirement states (which the state holds and the configuration no longer does).