@mark1russell7/stack-tofu 0.0.0-stage → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +421 -2
- package/build/add-on.d.ts +18 -0
- package/build/add-on.d.ts.map +1 -0
- package/build/add-on.js +28 -0
- package/build/add-on.js.map +1 -0
- package/build/check-COlnfceW.d.ts +154 -0
- package/build/check-COlnfceW.d.ts.map +1 -0
- package/build/index.d.ts +171 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +297 -0
- package/build/index.js.map +1 -0
- package/build/join-1KKMeraY.js +661 -0
- package/build/join-1KKMeraY.js.map +1 -0
- package/build/layer-C9IpaDIx.js +51 -0
- package/build/layer-C9IpaDIx.js.map +1 -0
- package/build/layer-MFHgwWfO.d.ts +118 -0
- package/build/layer-MFHgwWfO.d.ts.map +1 -0
- package/build/plan-B4mHDZjK.d.ts +68 -0
- package/build/plan-B4mHDZjK.d.ts.map +1 -0
- package/build/schema.d.ts +40 -0
- package/build/schema.d.ts.map +1 -0
- package/build/schema.js +126 -0
- package/build/schema.js.map +1 -0
- package/package.json +77 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mark Russell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,422 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @mark1russell7/stack-tofu
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
OpenTofu files from the records of a system stack. The package has a generator of the files and two gates. One gate holds a cost limit for each account, and one examines a plan.
|
|
4
|
+
|
|
5
|
+
It is the OpenTofu add-on of [`@mark1russell7/system-stack`](../system-stack/README.md). The core knows only parts and needs. This package tells how a part becomes a resource of [OpenTofu](https://opentofu.org/).
|
|
6
|
+
|
|
7
|
+
Nobody writes the files by hand. The files are a result of a query over the records, so they change when the stack changes.
|
|
8
|
+
|
|
9
|
+
The package knows no provider: the type of a resource and its arguments are data. Each function is a plain function with no clock, no network and no file.
|
|
10
|
+
|
|
11
|
+
## The rule
|
|
12
|
+
|
|
13
|
+
A resource has a cost in each month. The gate adds the planned cost of the resources of each account. It fails when an account has no hard limit, and when the planned cost is more than the limit.
|
|
14
|
+
|
|
15
|
+
The generator starts with the gate. A layer with an error gives no document. Thus a configuration above its cost limit stops before OpenTofu makes a plan.
|
|
16
|
+
|
|
17
|
+
A plan has its own gate. That gate fails when the plan destroys a resource that must stay, and when it changes a resource that no record has.
|
|
18
|
+
|
|
19
|
+
A gate that cannot read its input does not pass. An account with no budget is a fault, and a plan in an unknown format is a fault.
|
|
20
|
+
|
|
21
|
+
## The entries
|
|
22
|
+
|
|
23
|
+
| Entry | What it has |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| `@mark1russell7/stack-tofu` | The records of a layer, the queries, the cost of each account, the gate, the generator, the gate of a plan and a sample. |
|
|
26
|
+
| `@mark1russell7/stack-tofu/schema` | `tofuSchema` and `planSchema`, the zod schemas of a layer and of a plan, with `parseTofu` and `parsePlan`. |
|
|
27
|
+
| `@mark1russell7/stack-tofu/add-on` | `tofuAddOn`, the add-on in the form of the layer contract of the core. |
|
|
28
|
+
|
|
29
|
+
The root entry has no schema library. Thus a page that only shows a document gets no zod.
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npm install @mark1russell7/stack-tofu @mark1russell7/system-stack
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## A layer
|
|
38
|
+
|
|
39
|
+
An OpenTofu layer is one record with the resources of the parts, their providers and the variables. Its format has the name `tofu/1`. A stack keeps it in `Stack.layers`, with the key `tofu/1`.
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import type { TofuLayer } from "@mark1russell7/stack-tofu";
|
|
43
|
+
|
|
44
|
+
const layer: TofuLayer = {
|
|
45
|
+
schema: "tofu/1",
|
|
46
|
+
version: ">= 1.8",
|
|
47
|
+
providers: [{ name: "example", source: "example-org/example", version: "~> 2.0", part: "cloud-account", values: { token: { $var: "example_token" } } }],
|
|
48
|
+
variables: [{ name: "example_token", sensitive: true, description: "The token of the account of the cloud provider" }],
|
|
49
|
+
resources: [
|
|
50
|
+
{ part: "cloud-host", type: "example_disk", values: { size_gb: 10 }, cost: 1, keep: true },
|
|
51
|
+
{
|
|
52
|
+
part: "cloud-host",
|
|
53
|
+
type: "example_server",
|
|
54
|
+
values: { name: "alerts", size: "small", disk: { $ref: "example_disk.cloud-host.id" } },
|
|
55
|
+
cost: 6,
|
|
56
|
+
keep: true,
|
|
57
|
+
ignore: ["labels"],
|
|
58
|
+
},
|
|
59
|
+
{ part: "cloud-host", type: "example_firewall", values: { server: { $ref: "example_server.cloud-host.id" }, ports: [22, 443] }, cost: 0 },
|
|
60
|
+
{ part: "program-cloud", type: "terraform_data", values: { input: { release: "1.4.0" } } },
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`SAMPLE_TOFU` of the package is this layer. It is for `SAMPLE_STACK` of the core. Each name and each amount is an example: the provider `example` does not exist.
|
|
66
|
+
|
|
67
|
+
| Field of a resource | What it is |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
| `part` | The `id` of the part of the stack that the resource makes. One part can have two resources or more. |
|
|
70
|
+
| `type` | The type of the resource, for example `example_server`. |
|
|
71
|
+
| `name` | The name of the resource in the files. The default comes from the `id` of the part. |
|
|
72
|
+
| `provider` | The provider configuration of the resource. The default is the configuration with no alias whose name starts the type. |
|
|
73
|
+
| `values` | The arguments of the resource. |
|
|
74
|
+
| `cost` | The planned cost of the resource in a month. It is the standing price. The cost that grows with the use is not in it. |
|
|
75
|
+
| `keep` | `true`: the resource holds data or a name that must stay. |
|
|
76
|
+
| `ignore` | The attributes whose changes outside the files are permitted. |
|
|
77
|
+
| `import` | The id of an object that exists at the provider. The files import the object as this resource. |
|
|
78
|
+
|
|
79
|
+
| Field of a provider configuration | What it is |
|
|
80
|
+
| --- | --- |
|
|
81
|
+
| `name` | The local name of the provider. It is the first word of the types of its resources. |
|
|
82
|
+
| `source` | The address of the provider in a registry, for example `example-org/example`. |
|
|
83
|
+
| `version` | The versions of the provider that the files accept, for example `~> 2.0`. |
|
|
84
|
+
| `alias` | The alias of the configuration, when a provider has two configurations or more. |
|
|
85
|
+
| `part` | The `id` of the part that pays for the resources of the configuration: an account, a project or a tenant. |
|
|
86
|
+
| `values` | The arguments of the configuration. |
|
|
87
|
+
|
|
88
|
+
| Field of a variable | What it is |
|
|
89
|
+
| --- | --- |
|
|
90
|
+
| `name` | The name of the variable. |
|
|
91
|
+
| `type` | `string`, `number` or `bool`. The default is `string`. |
|
|
92
|
+
| `sensitive` | `true`: OpenTofu does not show the value. |
|
|
93
|
+
| `description` | A text for the person who gives the value. |
|
|
94
|
+
|
|
95
|
+
A secret is a variable, so no record holds its value. A variable has no default for that reason. A person or a program gives each value when OpenTofu runs.
|
|
96
|
+
|
|
97
|
+
A resource whose type starts with `terraform_` is a part of OpenTofu, for example `terraform_data`. It has no provider configuration, no account and no cost.
|
|
98
|
+
|
|
99
|
+
The field `backend` of a layer names the place where OpenTofu keeps its state. Each value of a backend is literal.
|
|
100
|
+
|
|
101
|
+
## The values
|
|
102
|
+
|
|
103
|
+
An argument is a value of JSON. Three forms have a meaning.
|
|
104
|
+
|
|
105
|
+
| Value | What OpenTofu reads |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| A text | The text as it is in the record. The generator escapes each template sequence. |
|
|
108
|
+
| `{ "$ref": "example_disk.cloud-host.id" }` | The attribute `id` of the resource `example_disk.cloud-host` of the layer. |
|
|
109
|
+
| `{ "$var": "example_token" }` | The value of the variable `example_token` of the layer. |
|
|
110
|
+
|
|
111
|
+
A text of a record is thus not an expression. A text with `${` in it stays that text, and it cannot read a file or a secret.
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import { renderValue } from "@mark1russell7/stack-tofu";
|
|
115
|
+
|
|
116
|
+
renderValue({ name: "a ${literal} text", disk: { $ref: "example_disk.cloud-host.id" }, token: { $var: "example_token" } });
|
|
117
|
+
// => { name: "a $${literal} text", disk: "${example_disk.cloud-host.id}", token: "${var.example_token}" }
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
A key that starts with `$` has no other use. The gate refuses an object with such a key that is not one of the two forms.
|
|
121
|
+
|
|
122
|
+
## The sequence of the resources
|
|
123
|
+
|
|
124
|
+
A person writes each dependence one time: in the needs of the stack. `dependsOn(layer, stack)` gives the dependencies of each resource from those needs.
|
|
125
|
+
|
|
126
|
+
- A resource depends on the resources of each part that its part needs.
|
|
127
|
+
- For a needed part with no resource, the walk goes on to the needs of that part.
|
|
128
|
+
- An address that the arguments of a resource read is not in the list. OpenTofu knows that dependence from the arguments.
|
|
129
|
+
|
|
130
|
+
In the sample, the part `program-cloud` needs `cloud-host`. Thus the resource that starts the program waits for the server, the disk and the firewall.
|
|
131
|
+
|
|
132
|
+
`resourceCycles(layer, stack)` gives the resources that wait for each other. `resourcesByPart(layer)` gives the addresses of the resources of each part, so a host joins a plan or a state to the parts.
|
|
133
|
+
|
|
134
|
+
## The gate
|
|
135
|
+
|
|
136
|
+
`checkTofu(layer, stack, { budgets })` gives the faults of a layer. A list with no error tells that the gate passes.
|
|
137
|
+
|
|
138
|
+
A budget is the hard limit of the cost of an account in a month. The states of a spend layer have this form, so a host gives `serviceStates` of [`@mark1russell7/stack-spend`](../stack-spend/README.md) as the budgets. The two add-ons do not know each other.
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
import { checkTofu, SAMPLE_BUDGETS, SAMPLE_TOFU } from "@mark1russell7/stack-tofu";
|
|
142
|
+
import { SAMPLE_STACK } from "@mark1russell7/system-stack";
|
|
143
|
+
|
|
144
|
+
checkTofu(SAMPLE_TOFU, SAMPLE_STACK, { budgets: SAMPLE_BUDGETS });
|
|
145
|
+
// => []: the planned cost of the cloud account is 7, and its hard limit is 10
|
|
146
|
+
|
|
147
|
+
checkTofu(SAMPLE_TOFU, SAMPLE_STACK, { budgets: [{ part: "cloud-account", hardLimit: 5 }], currency: "USD" }).map((fault) => `${fault.code}: ${fault.message}`);
|
|
148
|
+
// => ['cost-over: The planned cost of the resources of "cloud-account" is 7 USD for a month. Its hard limit is 5 USD.']
|
|
149
|
+
|
|
150
|
+
checkTofu(SAMPLE_TOFU, SAMPLE_STACK).map((fault) => fault.code);
|
|
151
|
+
// => ["budget-none"]: the gate has no read of the limit of the account
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
| Code | The fault |
|
|
155
|
+
| --- | --- |
|
|
156
|
+
| `version` | The versions of OpenTofu do not have the form of a list of versions. |
|
|
157
|
+
| `backend` | The type of the backend does not have the form of a type, or a value of the backend is not literal. |
|
|
158
|
+
| `variable-form` | The name of a variable does not have the form of a name. |
|
|
159
|
+
| `variable-duplicate` | Two variables have one name. |
|
|
160
|
+
| `provider-form` | The name, the alias, the source or the versions of a provider configuration do not have their form. |
|
|
161
|
+
| `provider-duplicate` | Two provider configurations have one address. |
|
|
162
|
+
| `provider-source` | Two configurations of one provider have different sources or versions. |
|
|
163
|
+
| `provider-part` | A provider configuration names no part of the stack. |
|
|
164
|
+
| `provider-value` | A value of a provider configuration reads a resource. |
|
|
165
|
+
| `resource-form` | The type, the name or the import id of a resource does not have its form. |
|
|
166
|
+
| `resource-duplicate` | Two resources have one address. |
|
|
167
|
+
| `resource-part` | A resource names no part of the stack. |
|
|
168
|
+
| `provider-none` | The layer does not have the provider configuration of a resource. |
|
|
169
|
+
| `ignore-form` | An attribute of `ignore` does not have the form of a path. |
|
|
170
|
+
| `value-name` | The name of an argument does not have the form of a name. |
|
|
171
|
+
| `value-meta` | An argument is a meta-argument, for example `lifecycle`. The generator writes each meta-argument. |
|
|
172
|
+
| `value-form` | An object has a key that starts with `$`, and it is not a correct reference or variable. |
|
|
173
|
+
| `value-number` | A number is not finite. JSON cannot hold it. |
|
|
174
|
+
| `ref-none` | A reference names a resource that the layer does not have. |
|
|
175
|
+
| `var-none` | A value names a variable that the layer does not have. |
|
|
176
|
+
| `cycle` | Resources wait for each other, so OpenTofu can make none of them. |
|
|
177
|
+
| `cost-amount` | The planned cost of a resource is less than 0 or not finite. |
|
|
178
|
+
| `cost-none` | A resource of a provider has no planned cost. A cost that is not known is not 0. |
|
|
179
|
+
| `cost-builtin` | A resource that is a part of OpenTofu has a planned cost above 0. It counts against no account. |
|
|
180
|
+
| `budget-duplicate` | Two budgets name one part. |
|
|
181
|
+
| `budget-amount` | The hard limit of a budget is less than 0 or not finite. |
|
|
182
|
+
| `budget-none` | No budget names an account with resources. |
|
|
183
|
+
| `limit-none` | The resources of an account have a planned cost above 0, and the account has no hard limit. |
|
|
184
|
+
| `cost-over` | The planned cost of an account is more than its hard limit. |
|
|
185
|
+
| `provider-need` | A warning: the part of a resource does not need the part of its provider configuration. |
|
|
186
|
+
| `variable-unused` | A warning: no value reads a variable. |
|
|
187
|
+
|
|
188
|
+
A fault has the address of its record in the field `at`, and the `id` of the part of the stack in the field `part`.
|
|
189
|
+
|
|
190
|
+
The gate does not examine the stack. `checkStack` of the core does, and the generator uses the two functions.
|
|
191
|
+
|
|
192
|
+
## The cost of each account
|
|
193
|
+
|
|
194
|
+
`accountStates(layer, budgets)` gives the planned cost of each account, from one Vex formula for each field. A page shows the same numbers that the gate examines.
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
import { accountStates, plannedTotal, SAMPLE_BUDGETS, SAMPLE_TOFU } from "@mark1russell7/stack-tofu";
|
|
198
|
+
|
|
199
|
+
accountStates(SAMPLE_TOFU, SAMPLE_BUDGETS);
|
|
200
|
+
// => [{
|
|
201
|
+
// part: "cloud-account",
|
|
202
|
+
// resources: ["example_disk.cloud-host", "example_firewall.cloud-host", "example_server.cloud-host"],
|
|
203
|
+
// planned: 7, unknown: 0, limit: 10, over: false, room: 3,
|
|
204
|
+
// }]
|
|
205
|
+
|
|
206
|
+
plannedTotal(SAMPLE_TOFU); // => 7
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
| Field of a state | What it is |
|
|
210
|
+
| --- | --- |
|
|
211
|
+
| `resources` | The addresses of the resources that count against the account. |
|
|
212
|
+
| `planned` | The sum of the planned costs of those resources in a month. |
|
|
213
|
+
| `unknown` | The count of the resources with no planned cost. The sum does not have them. |
|
|
214
|
+
| `limit` | The hard limit of the budget of the account. It is absent when no budget gives a correct amount. |
|
|
215
|
+
| `over` | If the planned cost is more than the limit. It is absent when the limit is absent. |
|
|
216
|
+
| `room` | The limit minus the planned cost. It is absent when the limit is absent. |
|
|
217
|
+
|
|
218
|
+
A planned cost that is equal to the limit is not over it.
|
|
219
|
+
|
|
220
|
+
## The generator
|
|
221
|
+
|
|
222
|
+
`generateTofu(layer, stack, { budgets })` gives the document of the files. It examines the stack and the layer first, and an error gives no document. A warning does not stop it.
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
import { DOCUMENT_FILE, documentText, generateTofu, SAMPLE_BUDGETS, SAMPLE_TOFU } from "@mark1russell7/stack-tofu";
|
|
226
|
+
import { SAMPLE_STACK } from "@mark1russell7/system-stack";
|
|
227
|
+
|
|
228
|
+
const made = generateTofu(SAMPLE_TOFU, SAMPLE_STACK, { budgets: SAMPLE_BUDGETS });
|
|
229
|
+
if (made.ok) documentText(made.document); // The text of the file DOCUMENT_FILE, "main.tf.json"
|
|
230
|
+
|
|
231
|
+
generateTofu(SAMPLE_TOFU, SAMPLE_STACK, { budgets: [{ part: "cloud-account", hardLimit: 5 }] });
|
|
232
|
+
// => { ok: false, faults: [{ level: "error", code: "cost-over", at: "cloud-account", ... }] }
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
The document is one file in the JSON form of OpenTofu. This is a piece of the document of the sample:
|
|
236
|
+
|
|
237
|
+
```json
|
|
238
|
+
{
|
|
239
|
+
"//": "The generator of @mark1russell7/stack-tofu made this file from the records of a stack. Do not edit it: change the records, and generate it again.",
|
|
240
|
+
"terraform": {
|
|
241
|
+
"required_version": ">= 1.8",
|
|
242
|
+
"required_providers": { "example": { "source": "example-org/example", "version": "~> 2.0" } }
|
|
243
|
+
},
|
|
244
|
+
"variable": {
|
|
245
|
+
"example_token": { "type": "string", "description": "The token of the account of the cloud provider", "sensitive": true }
|
|
246
|
+
},
|
|
247
|
+
"provider": { "example": [{ "token": "${var.example_token}" }] },
|
|
248
|
+
"resource": {
|
|
249
|
+
"example_server": {
|
|
250
|
+
"cloud-host": {
|
|
251
|
+
"//": "The part \"cloud-host\" of the stack.",
|
|
252
|
+
"name": "alerts",
|
|
253
|
+
"size": "small",
|
|
254
|
+
"disk": "${example_disk.cloud-host.id}",
|
|
255
|
+
"lifecycle": { "prevent_destroy": true, "ignore_changes": ["labels"] }
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
"terraform_data": {
|
|
259
|
+
"program-cloud": {
|
|
260
|
+
"//": "The part \"program-cloud\" of the stack.",
|
|
261
|
+
"input": { "release": "1.4.0" },
|
|
262
|
+
"depends_on": ["example_disk.cloud-host", "example_firewall.cloud-host", "example_server.cloud-host"]
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
- The same records give the same text, in each sequence of the records. Thus a change of the file in a review is a change of the records.
|
|
270
|
+
- The arguments of a resource keep the sequence of the record.
|
|
271
|
+
- A resource with `keep` gets `prevent_destroy`, so OpenTofu refuses a plan that destroys it.
|
|
272
|
+
- A resource with `import` gets an `import` block, so OpenTofu takes the object that exists.
|
|
273
|
+
- Each resource has a comment with the `id` of its part.
|
|
274
|
+
|
|
275
|
+
The generator writes no file. The host writes the text, because only the host knows the folder.
|
|
276
|
+
|
|
277
|
+
## The gate of a plan
|
|
278
|
+
|
|
279
|
+
OpenTofu makes a plan from the files and the state. `checkPlan(layer, plan, options)` gives the faults of the JSON of that plan, from the command `tofu show -json`. An empty list tells that the gate passes.
|
|
280
|
+
|
|
281
|
+
```ts
|
|
282
|
+
import { checkPlan, SAMPLE_PLAN, SAMPLE_TOFU } from "@mark1russell7/stack-tofu";
|
|
283
|
+
|
|
284
|
+
checkPlan(SAMPLE_TOFU, SAMPLE_PLAN);
|
|
285
|
+
// => []: the first plan makes each resource of the layer
|
|
286
|
+
|
|
287
|
+
checkPlan(SAMPLE_TOFU, SAMPLE_PLAN, { noChange: true }).map((fault) => fault.code);
|
|
288
|
+
// => ["plan-change", "plan-change", "plan-change", "plan-change"]
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
| Code | The fault |
|
|
292
|
+
| --- | --- |
|
|
293
|
+
| `plan-format` | The format of the plan has a different major version. The gate reads nothing more. |
|
|
294
|
+
| `plan-errored` | The plan has an error, so it is not complete. |
|
|
295
|
+
| `plan-action` | A change has an action that the gate does not know, or no action. |
|
|
296
|
+
| `plan-unknown` | The plan changes a resource that the layer does not have. No record tells its cost. |
|
|
297
|
+
| `plan-missing` | The plan does not have a resource of the layer. The plan is not a plan of these records. |
|
|
298
|
+
| `plan-destroy` | The plan deletes or replaces a resource whose record has `keep`. |
|
|
299
|
+
| `plan-delete` | The plan deletes a resource, and the option `removes` does not name it. |
|
|
300
|
+
| `plan-forget` | The plan removes a resource from the state and does not delete it. The object stays at the provider with no record. |
|
|
301
|
+
| `plan-import` | The import of a resource in the plan and the field `import` of its record do not agree. |
|
|
302
|
+
| `plan-change` | The option `noChange` is set, and the plan changes a resource. |
|
|
303
|
+
|
|
304
|
+
| Option | What it does |
|
|
305
|
+
| --- | --- |
|
|
306
|
+
| `noChange` | `true`: each change of a resource is a fault. Use it for the plan after an import, and for a check that the files and the state agree. |
|
|
307
|
+
| `removes` | The addresses of the resources that the plan can delete. |
|
|
308
|
+
|
|
309
|
+
A delete is thus a decision of a person. The person removes the record and names the address in `removes` for one run.
|
|
310
|
+
|
|
311
|
+
## The steps of a run
|
|
312
|
+
|
|
313
|
+
The package has no command and no network. A host does these steps.
|
|
314
|
+
|
|
315
|
+
1. Read the records, and use `generateTofu` with the budgets. Stop when it gives no document.
|
|
316
|
+
2. Write the text of the document to `main.tf.json` in an empty folder.
|
|
317
|
+
3. Start `tofu init`, then `tofu plan -out=plan.bin`.
|
|
318
|
+
4. Start `tofu show -json plan.bin`, and read the output with `parsePlan`.
|
|
319
|
+
5. Examine the plan with `checkPlan`. Stop when it gives a fault.
|
|
320
|
+
6. Start `tofu apply plan.bin`.
|
|
321
|
+
|
|
322
|
+
To take an object that exists, put its id in the field `import` of the record. Then do steps 1 to 5 with the option `noChange`. A plan with no change tells that the record and the object agree.
|
|
323
|
+
|
|
324
|
+
Do not keep a state file of OpenTofu in a public repository: it can hold secrets.
|
|
325
|
+
|
|
326
|
+
## The check with a real OpenTofu
|
|
327
|
+
|
|
328
|
+
The file `e2e/tofu.e2e.ts` does these steps with a real OpenTofu. The job `tofu` of the CI workflow starts it for each pull request. Each resource of the check is a `terraform_data`, so the check needs no provider and no account.
|
|
329
|
+
|
|
330
|
+
The check holds these facts:
|
|
331
|
+
|
|
332
|
+
- OpenTofu accepts the files of the generator, with no warning.
|
|
333
|
+
- A literal text with `${` or `%{` comes back as the record has it.
|
|
334
|
+
- A plan has one change with the action `no-op` for each resource that stays the same.
|
|
335
|
+
- A delete of a resource stops the gate until the option `removes` names its address.
|
|
336
|
+
- OpenTofu refuses a plan that replaces a resource with `keep`.
|
|
337
|
+
- An import of an object that exists gives a plan with no change.
|
|
338
|
+
|
|
339
|
+
To start the check on your computer, install OpenTofu. Then start `pnpm --filter @mark1russell7/stack-tofu run test:tofu`.
|
|
340
|
+
|
|
341
|
+
## The read of JSON
|
|
342
|
+
|
|
343
|
+
`parseTofu` and `parsePlan` of the entry `/schema` read the JSON of a layer and of a plan. Each gives its record, or the faults of the form with the place of each fault.
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
import { parseTofu } from "@mark1russell7/stack-tofu/schema";
|
|
347
|
+
|
|
348
|
+
parseTofu({ schema: "tofu/1", resources: [{ part: "cloud-host", type: 5 }] });
|
|
349
|
+
// => { ok: false, errors: ['The record "tofu/1" has a fault at "resources.0.type": Invalid input: expected string, received number'] }
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
The schema of a layer refuses a field that the format does not have. The schema of a plan keeps each field that it does not know, because a later version of OpenTofu can add fields.
|
|
353
|
+
|
|
354
|
+
The schema examines the form of a record. `checkTofu` and `checkPlan` examine the meaning of a record with a correct form.
|
|
355
|
+
|
|
356
|
+
## What the format does not have
|
|
357
|
+
|
|
358
|
+
The format `tofu/1` has resources, provider configurations, variables, one backend and imports. It does not have these parts of the language:
|
|
359
|
+
|
|
360
|
+
- Data sources, modules and outputs.
|
|
361
|
+
- The meta-arguments `count` and `for_each`, and provisioners.
|
|
362
|
+
- A default value of a variable.
|
|
363
|
+
|
|
364
|
+
A plan with a data source or a module gives the fault `plan-unknown`.
|
|
365
|
+
|
|
366
|
+
## The resources of some owners
|
|
367
|
+
|
|
368
|
+
`joinTofu(pieces)` joins the OpenTofu layers of the fragments of a stack into one layer. A piece is the layer of one fragment, with the name of the fragment.
|
|
369
|
+
|
|
370
|
+
- The resources, the provider configurations and the variables are in the order of the fragments.
|
|
371
|
+
- A resource address in two or more fragments is a fault. Equal resources give the fault too.
|
|
372
|
+
- The same rule holds for the address of a provider configuration and for the name of a variable.
|
|
373
|
+
- The layer has one `version`. A fragment with a different value is a fault.
|
|
374
|
+
- The state has one place. Thus a `backend` in two or more fragments is a fault.
|
|
375
|
+
|
|
376
|
+
A resource of one fragment can use a provider configuration or a variable of a different fragment.
|
|
377
|
+
|
|
378
|
+
```ts
|
|
379
|
+
import { joinTofu } from "@mark1russell7/stack-tofu";
|
|
380
|
+
|
|
381
|
+
const first = { schema: "tofu/1", version: ">= 1.8", backend: { type: "local" }, resources: [{ part: "one", type: "example_server" }] } as const;
|
|
382
|
+
|
|
383
|
+
joinTofu([
|
|
384
|
+
{ from: "a.json", layer: first },
|
|
385
|
+
{ from: "b.json", layer: { schema: "tofu/1", resources: [{ part: "two", type: "example_server" }] } },
|
|
386
|
+
]);
|
|
387
|
+
// => { ok: true, layer: { schema: "tofu/1", version: ">= 1.8", backend: { type: "local" }, resources: [{ part: "one", type: "example_server" }, { part: "two", type: "example_server" }] } }
|
|
388
|
+
|
|
389
|
+
joinTofu([
|
|
390
|
+
{ from: "a.json", layer: first },
|
|
391
|
+
{ from: "b.json", layer: { schema: "tofu/1", version: ">= 1.9", backend: { type: "local" }, resources: [{ part: "one", type: "example_server" }] } },
|
|
392
|
+
]);
|
|
393
|
+
// => {
|
|
394
|
+
// ok: false,
|
|
395
|
+
// errors: [
|
|
396
|
+
// 'The fragment "a.json" has the version of OpenTofu ">= 1.8", and the fragment "b.json" has ">= 1.9".',
|
|
397
|
+
// 'The fragments "a.json", "b.json" each have a backend. The state has one place.',
|
|
398
|
+
// 'The fragments "a.json", "b.json" each have the resource "example_server.one".',
|
|
399
|
+
// ],
|
|
400
|
+
// }
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
The add-on of the entry `/add-on` has the function as `join`. `joinStacks` of the core uses it for a stack in two or more documents, and the gate `checkTofu` examines the joined layer afterward.
|
|
404
|
+
|
|
405
|
+
The generator sorts the records. Thus it gives the same text of the file for each division of the records into fragments.
|
|
406
|
+
|
|
407
|
+
## The add-on for one check of a stack
|
|
408
|
+
|
|
409
|
+
`tofuAddOn` of the entry `/add-on` gives the add-on in the form of the layer contract. A host gives it to `checkStackLayers` of the core, with the add-ons of the other layers. A host with a stack in two or more documents gives it to `joinStacks` first.
|
|
410
|
+
|
|
411
|
+
```ts
|
|
412
|
+
import { tofuAddOn } from "@mark1russell7/stack-tofu/add-on";
|
|
413
|
+
import { checkStackLayers } from "@mark1russell7/system-stack";
|
|
414
|
+
|
|
415
|
+
checkStackLayers(stack, [tofuAddOn({ budgets })]);
|
|
416
|
+
// => the faults of the stack, then the faults of `checkTofu` for the layer `tofu/1`, each with the name of its layer
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
A layer with a wrong form gives one finding `layer-form` for each fault of the form, and the gate does not start. The add-on does not read the layer of a different add-on. The host gives the limit of each account as `budgets`, for example from the states of a spend layer.
|
|
420
|
+
|
|
421
|
+
## License
|
|
422
|
+
MIT
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { o as TofuOptions } from "./check-COlnfceW.js";
|
|
2
|
+
import { o as TofuLayer } from "./layer-MFHgwWfO.js";
|
|
3
|
+
import { StackJoiner } from "@mark1russell7/system-stack";
|
|
4
|
+
/**
|
|
5
|
+
* This function gives the OpenTofu add-on for a check with the budgets of the accounts.
|
|
6
|
+
*
|
|
7
|
+
* - `schema` is `tofu/1`, the key of the layer in `Stack.layers`.
|
|
8
|
+
* - `parse` is `parseTofu`.
|
|
9
|
+
* - `check` is the gate `checkTofu` with the options.
|
|
10
|
+
* - `join` is `joinTofu`. It joins the OpenTofu layers of the fragments of a stack.
|
|
11
|
+
*
|
|
12
|
+
* The add-on does not read the layer of a different add-on. A host reads the limits of the accounts, for example
|
|
13
|
+
* from the states of a spend layer, and gives them as `budgets`.
|
|
14
|
+
*
|
|
15
|
+
* @param options - The options of the gate. With no budgets, an account with resources stops the gate.
|
|
16
|
+
*/
|
|
17
|
+
export declare function tofuAddOn(options?: TofuOptions): StackJoiner<TofuLayer>;
|
|
18
|
+
//# sourceMappingURL=add-on.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-on.d.ts","names":[],"sources":["../src/add-on.ts"],"mappings":";;;;;;;;;;;;;;;;wBAsBgB,UAAU,UAAS,cAAmB,YAAY"}
|
package/build/add-on.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { a as checkTofu, t as joinTofu } from "./join-1KKMeraY.js";
|
|
2
|
+
import { n as TOFU_SCHEMA } from "./layer-C9IpaDIx.js";
|
|
3
|
+
import { parseTofu } from "./schema.js";
|
|
4
|
+
// src/add-on.ts
|
|
5
|
+
/**
|
|
6
|
+
* This function gives the OpenTofu add-on for a check with the budgets of the accounts.
|
|
7
|
+
*
|
|
8
|
+
* - `schema` is `tofu/1`, the key of the layer in `Stack.layers`.
|
|
9
|
+
* - `parse` is `parseTofu`.
|
|
10
|
+
* - `check` is the gate `checkTofu` with the options.
|
|
11
|
+
* - `join` is `joinTofu`. It joins the OpenTofu layers of the fragments of a stack.
|
|
12
|
+
*
|
|
13
|
+
* The add-on does not read the layer of a different add-on. A host reads the limits of the accounts, for example
|
|
14
|
+
* from the states of a spend layer, and gives them as `budgets`.
|
|
15
|
+
*
|
|
16
|
+
* @param options - The options of the gate. With no budgets, an account with resources stops the gate.
|
|
17
|
+
*/
|
|
18
|
+
function tofuAddOn(options = {}) {
|
|
19
|
+
return {
|
|
20
|
+
schema: TOFU_SCHEMA,
|
|
21
|
+
parse: parseTofu,
|
|
22
|
+
check: (layer, stack) => checkTofu(layer, stack, options),
|
|
23
|
+
join: joinTofu
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export { tofuAddOn };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=add-on.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-on.js","names":[],"sources":["../src/add-on.ts"],"sourcesContent":["import type { StackJoiner } from \"@mark1russell7/system-stack\";\nimport { checkTofu, type TofuOptions } from \"./check.ts\";\nimport { joinTofu } from \"./join.ts\";\nimport { TOFU_SCHEMA, type TofuLayer } from \"./layer.ts\";\nimport { parseTofu } from \"./schema.ts\";\n\n// The OpenTofu add-on in the form of the layer contract. A host gives it to `checkStackLayers` and to `joinStacks` of the core.\n// This entry has the schema library, so the root entry does not import it.\n\n/**\n * This function gives the OpenTofu add-on for a check with the budgets of the accounts.\n *\n * - `schema` is `tofu/1`, the key of the layer in `Stack.layers`.\n * - `parse` is `parseTofu`.\n * - `check` is the gate `checkTofu` with the options.\n * - `join` is `joinTofu`. It joins the OpenTofu layers of the fragments of a stack.\n *\n * The add-on does not read the layer of a different add-on. A host reads the limits of the accounts, for example\n * from the states of a spend layer, and gives them as `budgets`.\n *\n * @param options - The options of the gate. With no budgets, an account with resources stops the gate.\n */\nexport function tofuAddOn(options: TofuOptions = {}): StackJoiner<TofuLayer> {\n return { schema: TOFU_SCHEMA, parse: parseTofu, check: (layer, stack) => checkTofu(layer, stack, options), join: joinTofu };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,SAAgB,UAAU,UAAuB,CAAC,GAA2B;CAC3E,OAAO;EAAE,QAAQ;EAAa,OAAO;EAAW,QAAQ,OAAO,UAAU,UAAU,OAAO,OAAO,OAAO;EAAG,MAAM;CAAS;AAC5H"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { o as TofuLayer } from "./layer-MFHgwWfO.js";
|
|
2
|
+
import { Fault, Stack } from "@mark1russell7/system-stack";
|
|
3
|
+
import { Expr, Result, Space } from "@mark1russell7/vex";
|
|
4
|
+
/**
|
|
5
|
+
* The limit of the cost of a part for a month. A state of a service of the spend add-on has this form.
|
|
6
|
+
* Thus a host gives the states of a spend layer as the budgets, and the two add-ons do not know each other.
|
|
7
|
+
*/
|
|
8
|
+
interface Budget {
|
|
9
|
+
/** The `id` of the part: an account, a project or a tenant. */
|
|
10
|
+
readonly part: string;
|
|
11
|
+
/** The hard limit of the cost of the part for a month. A part with no hard limit has none. */
|
|
12
|
+
readonly hardLimit?: number | undefined;
|
|
13
|
+
}
|
|
14
|
+
/** The key of the layer node: the root of the cost tree. */
|
|
15
|
+
declare const COST_LAYER_KEY = "layer";
|
|
16
|
+
/** This function gives the key of the node of an account: the text `account:` and the `id` of its part. */
|
|
17
|
+
declare function accountKey(part: string): string;
|
|
18
|
+
/** This function gives the key of the node of a resource: the text `resource:` and its address. */
|
|
19
|
+
declare function resourceKey(address: string): string;
|
|
20
|
+
/** This function tells if a value is a finite number, 0 or more. */
|
|
21
|
+
declare function isZeroOrMore(value: number): boolean;
|
|
22
|
+
/** This function gives the first budget of each part, by the `id` of the part. */
|
|
23
|
+
declare function budgetsByPart(budgets: readonly Budget[]): Map<string, Budget>;
|
|
24
|
+
/** The planned cost of an account in a month: the sum of the known costs of its resources. The program evaluates at an account node. */
|
|
25
|
+
declare const PLANNED: Expr;
|
|
26
|
+
/** The count of the resources of an account with no known cost. The program evaluates at an account node. */
|
|
27
|
+
declare const UNKNOWN_COSTS: Expr;
|
|
28
|
+
/** This test tells if the planned cost of an account is more than its hard limit. An account with no hard limit gives an error value. */
|
|
29
|
+
declare const PLANNED_OVER: Expr;
|
|
30
|
+
/** The room of an account: its hard limit less its planned cost. An account with no hard limit gives an error value. */
|
|
31
|
+
declare const PLANNED_ROOM: Expr;
|
|
32
|
+
/** The planned cost of the layer in a month: the sum of the planned costs of its accounts. The program evaluates at the layer node. */
|
|
33
|
+
declare const PLANNED_TOTAL: Expr;
|
|
34
|
+
/**
|
|
35
|
+
* This function gives the cost tree of a layer, as a space of Vex.
|
|
36
|
+
*
|
|
37
|
+
* - The layer is the root, with the key `COST_LAYER_KEY`.
|
|
38
|
+
* - An account is a child of the layer: the part of a provider configuration that has one resource or more. Its field `limit` is its hard limit.
|
|
39
|
+
* - A resource is a child of the account of its provider configuration. Its field `cost` is its planned cost.
|
|
40
|
+
*
|
|
41
|
+
* A cost or a limit that is less than 0 or not finite is not in the tree: it is not known.
|
|
42
|
+
* A resource with no provider configuration is not in the tree, because it counts against no account.
|
|
43
|
+
*/
|
|
44
|
+
declare function costSpace(layer: TofuLayer, budgets?: readonly Budget[]): Space;
|
|
45
|
+
/**
|
|
46
|
+
* This function evaluates a program of this module at a node of a cost tree. It gives the value, or the error value.
|
|
47
|
+
* `tree` is the result of `costSpace`, and `key` is the key of a node.
|
|
48
|
+
*/
|
|
49
|
+
declare function evaluateCost(program: Expr, tree: Space, key: string): Result<unknown>;
|
|
50
|
+
/** The state of the planned cost of one account of a layer. */
|
|
51
|
+
interface AccountState {
|
|
52
|
+
/** The `id` of the part of the account. */
|
|
53
|
+
readonly part: string;
|
|
54
|
+
/** The addresses of the resources that count against the account, sorted. */
|
|
55
|
+
readonly resources: readonly string[];
|
|
56
|
+
/** The planned cost of the account in a month: the sum of the known costs of its resources. */
|
|
57
|
+
readonly planned: number;
|
|
58
|
+
/** The count of the resources with no known cost. With one or more, `planned` is not the whole cost. */
|
|
59
|
+
readonly unknown: number;
|
|
60
|
+
/** The hard limit of the account for a month. An account with no budget, or with a budget with no hard limit, has none. */
|
|
61
|
+
readonly limit?: number | undefined;
|
|
62
|
+
/** `true`: the planned cost is more than the hard limit. An account with no hard limit has no value. */
|
|
63
|
+
readonly over?: boolean | undefined;
|
|
64
|
+
/** The hard limit less the planned cost. An account with no hard limit has no value. */
|
|
65
|
+
readonly room?: number | undefined;
|
|
66
|
+
}
|
|
67
|
+
/** This function gives the state of the planned cost of each account of a layer, in the sequence of the first resource of each account. */
|
|
68
|
+
declare function accountStates(layer: TofuLayer, budgets?: readonly Budget[]): AccountState[];
|
|
69
|
+
/** This function gives the planned cost of a layer in a month: the sum of the planned costs of its accounts. */
|
|
70
|
+
declare function plannedTotal(layer: TofuLayer): number;
|
|
71
|
+
/** These are the codes of the faults of an OpenTofu layer. */
|
|
72
|
+
declare const TOFU_CODES: readonly ["version", "backend", "variable-form", "variable-duplicate", "provider-form", "provider-duplicate", "provider-source", "provider-part", "provider-value", "resource-form", "resource-duplicate", "resource-part", "provider-none", "ignore-form", "value-name", "value-meta", "value-form", "value-number", "ref-none", "var-none", "cycle", "cost-amount", "cost-none", "cost-builtin", "budget-duplicate", "budget-amount", "budget-none", "limit-none", "cost-over", "provider-need", "variable-unused"];
|
|
73
|
+
/** A code of a fault of an OpenTofu layer. */
|
|
74
|
+
type TofuCode = (typeof TOFU_CODES)[number];
|
|
75
|
+
/**
|
|
76
|
+
* A fault of an OpenTofu layer. Its field `at` is the place of the fault in the files.
|
|
77
|
+
*
|
|
78
|
+
* - For a resource, `at` is its address.
|
|
79
|
+
* - For a provider configuration, `at` is `provider.` and its address.
|
|
80
|
+
* - For a variable, `at` is `var.` and its name.
|
|
81
|
+
* - For the settings, `at` is `terraform`.
|
|
82
|
+
*
|
|
83
|
+
* For a fault of a budget or of an account, `at` is the `id` of the part.
|
|
84
|
+
*/
|
|
85
|
+
interface TofuFault extends Fault {
|
|
86
|
+
readonly code: TofuCode;
|
|
87
|
+
/** The `id` of the part of the stack of the record with the fault. */
|
|
88
|
+
readonly part?: string | undefined;
|
|
89
|
+
}
|
|
90
|
+
/** The options of the gate and of the generator. */
|
|
91
|
+
interface TofuOptions {
|
|
92
|
+
/**
|
|
93
|
+
* The limit of the cost of each account for a month. The states of a spend layer have this form.
|
|
94
|
+
* An account with resources and no budget stops the gate: the gate has no read of its limit.
|
|
95
|
+
*/
|
|
96
|
+
readonly budgets?: readonly Budget[] | undefined;
|
|
97
|
+
/** The currency of the costs and of the budgets, for the text of a fault. */
|
|
98
|
+
readonly currency?: string | undefined;
|
|
99
|
+
}
|
|
100
|
+
/** These arguments of a resource are meta-arguments. The generator writes them from the records, so the arguments of a record cannot have them. */
|
|
101
|
+
declare const RESOURCE_META: readonly string[];
|
|
102
|
+
/** These arguments of a provider configuration are meta-arguments. The generator writes them from the records. */
|
|
103
|
+
declare const PROVIDER_META: readonly string[];
|
|
104
|
+
/**
|
|
105
|
+
* This function gives each fault of an OpenTofu layer for a stack. A list with no error tells that the gate passes.
|
|
106
|
+
*
|
|
107
|
+
* The settings, the variables and the providers, as errors:
|
|
108
|
+
* - `version`: the versions of OpenTofu do not have the form of a list of versions.
|
|
109
|
+
* - `backend`: the type of the backend does not have the form of a type, or a value of the backend is not literal.
|
|
110
|
+
* - `variable-form`: the name of a variable does not have the form of a name.
|
|
111
|
+
* - `variable-duplicate`: two variables have one name.
|
|
112
|
+
* - `provider-form`: the name, the alias, the source or the versions of a provider configuration do not have their form.
|
|
113
|
+
* - `provider-duplicate`: two provider configurations have one address.
|
|
114
|
+
* - `provider-source`: two configurations of one provider have different sources or versions.
|
|
115
|
+
* - `provider-part`: a provider configuration names no part of the stack.
|
|
116
|
+
* - `provider-value`: a value of a provider configuration reads a resource.
|
|
117
|
+
*
|
|
118
|
+
* The resources, as errors:
|
|
119
|
+
* - `resource-form`: the type, the name or the import id of a resource does not have its form.
|
|
120
|
+
* - `resource-duplicate`: two resources have one address.
|
|
121
|
+
* - `resource-part`: a resource names no part of the stack.
|
|
122
|
+
* - `provider-none`: the layer does not have the provider configuration of a resource.
|
|
123
|
+
* - `ignore-form`: an attribute of `ignore` does not have the form of a path.
|
|
124
|
+
*
|
|
125
|
+
* The values, as errors:
|
|
126
|
+
* - `value-name`: the name of an argument does not have the form of a name.
|
|
127
|
+
* - `value-meta`: an argument is a meta-argument. The generator writes each meta-argument.
|
|
128
|
+
* - `value-form`: an object has a key that starts with `$`, and it is not a correct reference or variable.
|
|
129
|
+
* - `value-number`: a number is not finite. JSON cannot hold it.
|
|
130
|
+
* - `ref-none`: a reference names a resource that the layer does not have.
|
|
131
|
+
* - `var-none`: a value names a variable that the layer does not have.
|
|
132
|
+
*
|
|
133
|
+
* The queries, as errors:
|
|
134
|
+
* - `cycle`: resources wait for each other, so OpenTofu can make none of them.
|
|
135
|
+
*
|
|
136
|
+
* The costs, as errors:
|
|
137
|
+
* - `cost-amount`: the planned cost of a resource is less than 0 or not finite.
|
|
138
|
+
* - `cost-none`: a resource of a provider has no planned cost. A cost that is not known is not 0.
|
|
139
|
+
* - `cost-builtin`: a resource that is a part of OpenTofu has a planned cost above 0. It counts against no account.
|
|
140
|
+
* - `budget-duplicate`: two budgets name one part.
|
|
141
|
+
* - `budget-amount`: the hard limit of a budget is less than 0 or not finite.
|
|
142
|
+
* - `budget-none`: no budget names an account with resources. The gate has no read of its limit, so it does not pass.
|
|
143
|
+
* - `limit-none`: the resources of an account have a planned cost above 0, and the account has no hard limit.
|
|
144
|
+
* - `cost-over`: the planned cost of an account is more than its hard limit.
|
|
145
|
+
*
|
|
146
|
+
* The warnings:
|
|
147
|
+
* - `provider-need`: the part of a resource does not need the part of its provider configuration. The stack does not show that dependence.
|
|
148
|
+
* - `variable-unused`: no value reads a variable.
|
|
149
|
+
*
|
|
150
|
+
* The gate does not examine the stack: `checkStack` of the core does. The function is pure.
|
|
151
|
+
*/
|
|
152
|
+
declare function checkTofu(layer: TofuLayer, stack: Stack, options?: TofuOptions): TofuFault[];
|
|
153
|
+
export { resourceKey as C, plannedTotal as S, accountStates as _, TofuFault as a, evaluateCost as b, AccountState as c, PLANNED as d, PLANNED_OVER as f, accountKey as g, UNKNOWN_COSTS as h, TofuCode as i, Budget as l, PLANNED_TOTAL as m, RESOURCE_META as n, TofuOptions as o, PLANNED_ROOM as p, TOFU_CODES as r, checkTofu as s, PROVIDER_META as t, COST_LAYER_KEY as u, budgetsByPart as v, isZeroOrMore as x, costSpace as y };
|
|
154
|
+
//# sourceMappingURL=check-COlnfceW.d.ts.map
|