@intentius/chant-lexicon-terraform 0.124.78 → 0.124.79
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/dist/change-set.d.ts +1 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +19 -0
- package/dist/components/capability-plugin.d.ts +9 -1
- package/dist/components/capability-plugin.d.ts.map +1 -1
- package/dist/components/capability-plugin.js +44 -22
- package/dist/integrity.json +2 -2
- package/dist/manifest.json +1 -1
- package/dist/op/activities/terraform.d.ts +11 -0
- package/dist/op/activities/terraform.d.ts.map +1 -1
- package/dist/op/activities/terraform.js +9 -1
- package/dist/terragrunt/capability.d.ts +129 -0
- package/dist/terragrunt/capability.d.ts.map +1 -0
- package/dist/terragrunt/capability.js +347 -0
- package/dist/terragrunt/index.d.ts +3 -1
- package/dist/terragrunt/index.d.ts.map +1 -1
- package/dist/terragrunt/index.js +3 -1
- package/dist/terragrunt/units.d.ts +9 -0
- package/dist/terragrunt/units.d.ts.map +1 -1
- package/dist/terragrunt/units.js +25 -0
- package/package.json +2 -2
- package/src/change-set.test.ts +27 -1
- package/src/change-set.ts +19 -0
- package/src/components/capability-plugin.test.ts +61 -6
- package/src/components/capability-plugin.ts +48 -23
- package/src/components/compose-op-wave.test.ts +134 -0
- package/src/op/activities/terraform.test.ts +21 -0
- package/src/op/activities/terraform.ts +20 -1
- package/src/terragrunt/capability.test.ts +327 -0
- package/src/terragrunt/capability.ts +431 -0
- package/src/terragrunt/index.ts +3 -1
- package/src/terragrunt/units.ts +25 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `terragrunt-apply` (#4842): Terragrunt units as an op wave's step. A
|
|
3
|
+
* `discover` wave finds its units at plan time from `terragrunt find`, and a
|
|
4
|
+
* `together` wave plans and applies them with one `terragrunt run --all`, the
|
|
5
|
+
* way a Terragrunt repo runs a layer of its graph:
|
|
6
|
+
*
|
|
7
|
+
* ```json
|
|
8
|
+
* { "step": { "kind": "terragrunt-apply", "unit": "{target}" },
|
|
9
|
+
* "waves": [{ "name": "layer", "runs": [], "discover": true, "together": true },
|
|
10
|
+
* { "name": "rest", "runs": [], "discover": true, "together": true, "rest": true }] }
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* - `discoverRuns` runs `terragrunt find` and cuts the units into waves by
|
|
14
|
+
* their dependencies (`terragruntWaves`), or, with `layers`, cuts each
|
|
15
|
+
* listed wave again by the graph (`terragruntListedWaves`). It answers
|
|
16
|
+
* wave k's units and how many waves there are.
|
|
17
|
+
* - `planGroup` plans the wave's units with one `run --all` into the work
|
|
18
|
+
* directory (`planTerragruntWave`, which refuses a wave that would read
|
|
19
|
+
* `mock_outputs`). Each unit's member is its change-set part, and its
|
|
20
|
+
* artifact names its plan JSON (`planJson`), which a cost hold and the
|
|
21
|
+
* after-plan hooks read. A unit that did not plan fails the wave.
|
|
22
|
+
* - `runGroup` applies exactly those saved plans with one `run --all`
|
|
23
|
+
* (`applyTerragruntWave`) and says how each unit's part ended.
|
|
24
|
+
* - `plan` and `run` do the same for one unit, for a wave planned run by
|
|
25
|
+
* run (a share job's slice).
|
|
26
|
+
*
|
|
27
|
+
* A run hook's `processEnv` is laid over the environment Terragrunt runs
|
|
28
|
+
* with; the units of one `run --all` must agree on it. Terragrunt has no
|
|
29
|
+
* init of its own before the plan, so `afterInit` is called before it plans.
|
|
30
|
+
* A product passes its own `exec` (`terragruntApplyCapability`) to wrap
|
|
31
|
+
* Terragrunt, as terragucci adds its lock timeout and its backend bootstrap.
|
|
32
|
+
*
|
|
33
|
+
* A unit may pin its own releases (#4849): the binary Terragrunt calls and
|
|
34
|
+
* Terragrunt itself. One `run --all` runs one Terragrunt with one
|
|
35
|
+
* `TG_TF_PATH`, so `resolveUnit` says what each unit runs, and a wave plans
|
|
36
|
+
* and applies as one `run --all` per pair of releases, each in a work
|
|
37
|
+
* directory of its own. The units of a wave read none of each other, so
|
|
38
|
+
* splitting it changes only how many processes run it. Each unit keeps its
|
|
39
|
+
* member digest, and the wave its `(wave plan)` member. A product passes its
|
|
40
|
+
* own resolver (terragucci's `UnitBinaries`), or
|
|
41
|
+
* {@link terragruntUnitPinResolver}, which reads the pins from the units'
|
|
42
|
+
* files and asks the product where each pinned release is.
|
|
43
|
+
*/
|
|
44
|
+
import { createHash } from "node:crypto";
|
|
45
|
+
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
46
|
+
import { basename, join } from "node:path";
|
|
47
|
+
import { computePlanDigest } from "@intentius/chant/lifecycle/plan-digest";
|
|
48
|
+
import { applyTerragruntWave, defaultTerragruntExec, discoverTerragruntUnits, planTerragruntWave, TerragruntMockRefusal } from "./run.js";
|
|
49
|
+
import { terragruntListedWaves, terragruntWaves } from "./units.js";
|
|
50
|
+
/** The binaries a unit may pin a release of, and the file that pins each. */
|
|
51
|
+
const VERSION_FILES = { tofu: ".opentofu-version", terraform: ".terraform-version" };
|
|
52
|
+
const RELEASE = /^\d+\.\d+\.\d+(-[0-9A-Za-z.]+)?$/;
|
|
53
|
+
const stripComments = (text) => text.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:"])(#|\/\/).*$/gm, "$1");
|
|
54
|
+
/** Every exact `required_version` (`= 1.13.1` or `1.13.1`) in one directory's Terraform files. */
|
|
55
|
+
function exactRequiredVersions(dir) {
|
|
56
|
+
let names;
|
|
57
|
+
try {
|
|
58
|
+
names = readdirSync(dir).filter((n) => n.endsWith(".tf") || n.endsWith(".tofu") || n.endsWith(".tf.json") || n.endsWith(".tofu.json"));
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
const out = [];
|
|
64
|
+
for (const n of names) {
|
|
65
|
+
const f = join(dir, n);
|
|
66
|
+
if (!statSync(f).isFile())
|
|
67
|
+
continue;
|
|
68
|
+
const m = stripComments(readFileSync(f, "utf-8")).match(/required_version\s*=\s*"\s*=?\s*(\d+\.\d+\.\d+)\s*"/);
|
|
69
|
+
if (m && !out.includes(m[1]))
|
|
70
|
+
out.push(m[1]);
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* What `unit` (relative to `dir`) pins, read as terragucci reads it: the
|
|
76
|
+
* binary from a `.opentofu-version` (tofu) or `.terraform-version`
|
|
77
|
+
* (terraform), whose first line that is not a comment is an exact release,
|
|
78
|
+
* else one exact `required_version` in its Terraform files; Terragrunt from
|
|
79
|
+
* an exact `terragrunt_version_constraint` (`"= 1.1.5"`) in its
|
|
80
|
+
* `terragrunt.hcl`. `binary` is the one the step runs: only tofu and
|
|
81
|
+
* terraform are pinned. A product's own pins, such as terragucci.yml's
|
|
82
|
+
* `version` map, go in its own resolver.
|
|
83
|
+
*/
|
|
84
|
+
export function terragruntUnitPins(dir, unit, binary) {
|
|
85
|
+
const at = join(dir, unit);
|
|
86
|
+
const out = {};
|
|
87
|
+
const name = basename(binary);
|
|
88
|
+
if (name === "tofu" || name === "terraform") {
|
|
89
|
+
const file = join(at, VERSION_FILES[name]);
|
|
90
|
+
const line = existsSync(file) ? readFileSync(file, "utf-8").split("\n").map((l) => l.trim()).find((l) => l !== "" && !l.startsWith("#")) : undefined;
|
|
91
|
+
const v = line?.replace(/^v/, "");
|
|
92
|
+
const required = exactRequiredVersions(at);
|
|
93
|
+
if (v && RELEASE.test(v))
|
|
94
|
+
out.binary = { tool: name, version: v, source: VERSION_FILES[name] };
|
|
95
|
+
else if (required.length === 1)
|
|
96
|
+
out.binary = { tool: name, version: required[0], source: "required_version" };
|
|
97
|
+
}
|
|
98
|
+
const hcl = join(at, "terragrunt.hcl");
|
|
99
|
+
if (existsSync(hcl)) {
|
|
100
|
+
const text = readFileSync(hcl, "utf-8").replace(/(^|[^:"])(#|\/\/).*$/gm, "$1");
|
|
101
|
+
const tg = /^\s*terragrunt_version_constraint\s*=\s*"\s*=?\s*v?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.]+)?)\s*"/m.exec(text)?.[1];
|
|
102
|
+
if (tg)
|
|
103
|
+
out.terragrunt = { version: tg, source: "terragrunt_version_constraint" };
|
|
104
|
+
}
|
|
105
|
+
return out;
|
|
106
|
+
}
|
|
107
|
+
/** A {@link TerragruntUnitResolver} from the units' own pins ({@link terragruntUnitPins}). The step's `binary` defaults to tofu, as Terragrunt's does. */
|
|
108
|
+
export function terragruntUnitPinResolver(options) {
|
|
109
|
+
const releases = new Map();
|
|
110
|
+
const releaseOf = (tool, version, unit) => {
|
|
111
|
+
const key = `${tool}@${version}`;
|
|
112
|
+
let p = releases.get(key);
|
|
113
|
+
if (!p) {
|
|
114
|
+
p = Promise.resolve(options.release(tool, version, unit));
|
|
115
|
+
releases.set(key, p);
|
|
116
|
+
}
|
|
117
|
+
return p;
|
|
118
|
+
};
|
|
119
|
+
return async (unit, input) => {
|
|
120
|
+
const pins = terragruntUnitPins(dirOf(input), unit, input.binary ?? "tofu");
|
|
121
|
+
const out = {};
|
|
122
|
+
if (pins.binary && pins.binary.version !== options.carried?.[pins.binary.tool])
|
|
123
|
+
out.binary = await releaseOf(pins.binary.tool, pins.binary.version, unit);
|
|
124
|
+
if (pins.terragrunt && pins.terragrunt.version !== options.carried?.terragrunt)
|
|
125
|
+
out.terragrunt = await releaseOf("terragrunt", pins.terragrunt.version, unit);
|
|
126
|
+
return out;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
const DEFAULT_WORK_DIR = ".chant/terragrunt-apply";
|
|
130
|
+
const dirOf = (input) => input.dir ?? process.cwd();
|
|
131
|
+
/** The work directory of a `run --all` over `units`: one per set of units, so a wave and a unit of it never share one. */
|
|
132
|
+
function workDirOf(input, units) {
|
|
133
|
+
const key = createHash("sha256").update(JSON.stringify([...units].sort())).digest("hex").slice(0, 16);
|
|
134
|
+
return join(input.workDir ?? DEFAULT_WORK_DIR, key);
|
|
135
|
+
}
|
|
136
|
+
/** `exec` with `env` laid over what each call adds. */
|
|
137
|
+
function withEnv(exec, env) {
|
|
138
|
+
if (!env)
|
|
139
|
+
return exec;
|
|
140
|
+
return (file, args, o) => exec(file, args, { ...o, env: { ...o.env, ...env } });
|
|
141
|
+
}
|
|
142
|
+
/** The settings every unit of one `run --all` shares; throws when members disagree. */
|
|
143
|
+
function shared(members) {
|
|
144
|
+
if (members.length === 0)
|
|
145
|
+
throw new Error("terragrunt-apply: a wave needs at least one unit");
|
|
146
|
+
const inputs = members.map((m) => m.input ?? m.step);
|
|
147
|
+
for (const i of inputs)
|
|
148
|
+
if (typeof i.unit !== "string" || i.unit === "")
|
|
149
|
+
throw new Error("terragrunt-apply: each run names its unit");
|
|
150
|
+
const first = inputs[0];
|
|
151
|
+
const key = (i) => JSON.stringify([i.dir, i.terragrunt, i.binary, i.parallelism, i.workDir, i.destroy === true]);
|
|
152
|
+
if (inputs.some((i) => key(i) !== key(first)))
|
|
153
|
+
throw new Error("terragrunt-apply: the wave's units run as one run --all, so they need the same dir, terragrunt, binary, parallelism, workDir and destroy");
|
|
154
|
+
const envs = members.map((m) => JSON.stringify(m.ctx.processEnv ?? {}));
|
|
155
|
+
if (envs.some((e) => e !== envs[0]))
|
|
156
|
+
throw new Error("terragrunt-apply: the wave's units run as one run --all with one environment, and the run hooks gave them different ones");
|
|
157
|
+
const env = members[0].ctx.processEnv;
|
|
158
|
+
return { input: first, units: inputs.map((i) => i.unit), ...(env ? { env } : {}) };
|
|
159
|
+
}
|
|
160
|
+
/** Each unit's plan from a planned wave, or throws naming each unit that did not plan. */
|
|
161
|
+
function unitPlans(parts, units, workDir, dir) {
|
|
162
|
+
const failed = parts.filter((p) => p.member.status === "failed" || typeof p.member.planDigest !== "string");
|
|
163
|
+
if (failed.length > 0)
|
|
164
|
+
throw new Error(`terragrunt-apply: ${failed.map((p) => `${p.member.member}: ${p.member.error ?? "not planned"}`).join("; ")}`);
|
|
165
|
+
const out = new Map();
|
|
166
|
+
for (const part of parts) {
|
|
167
|
+
const unit = part.member.member;
|
|
168
|
+
const artifact = { kind: "terragrunt-apply-unit", workDir, unit, planJson: join(dir, workDir, "json", unit, "tfplan.json") };
|
|
169
|
+
out.set(unit, { member: unit, planDigest: part.member.planDigest, artifact, changeSet: part });
|
|
170
|
+
}
|
|
171
|
+
const missing = units.filter((u) => !out.has(u));
|
|
172
|
+
if (missing.length > 0)
|
|
173
|
+
throw new Error(`terragrunt-apply: Terragrunt planned no ${missing.join(", ")}`);
|
|
174
|
+
return out;
|
|
175
|
+
}
|
|
176
|
+
async function planUnits(exec, input, units, env) {
|
|
177
|
+
const dir = dirOf(input);
|
|
178
|
+
const workDir = workDirOf(input, units);
|
|
179
|
+
const planned = await planTerragruntWave({
|
|
180
|
+
dir,
|
|
181
|
+
units,
|
|
182
|
+
workDir,
|
|
183
|
+
exec: withEnv(exec, env),
|
|
184
|
+
...(input.terragrunt ? { terragrunt: input.terragrunt } : {}),
|
|
185
|
+
...(input.binary ? { binary: input.binary } : {}),
|
|
186
|
+
...(input.parallelism !== undefined ? { parallelism: input.parallelism } : {}),
|
|
187
|
+
...(input.destroy ? { destroy: true } : {}),
|
|
188
|
+
});
|
|
189
|
+
return { workDir, plans: unitPlans(planned.parts, units, workDir, dir) };
|
|
190
|
+
}
|
|
191
|
+
async function applyUnits(exec, input, units, workDir, env) {
|
|
192
|
+
return applyTerragruntWave({
|
|
193
|
+
dir: dirOf(input),
|
|
194
|
+
units,
|
|
195
|
+
workDir,
|
|
196
|
+
exec: withEnv(exec, env),
|
|
197
|
+
...(input.terragrunt ? { terragrunt: input.terragrunt } : {}),
|
|
198
|
+
...(input.binary ? { binary: input.binary } : {}),
|
|
199
|
+
...(input.parallelism !== undefined ? { parallelism: input.parallelism } : {}),
|
|
200
|
+
...(input.destroy ? { destroy: true } : {}),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/** The step's input with what `unit` runs in place of the step's `terragrunt` and `binary`. */
|
|
204
|
+
async function unitInput(resolveUnit, input, unit) {
|
|
205
|
+
if (!resolveUnit)
|
|
206
|
+
return input;
|
|
207
|
+
const t = await resolveUnit(unit, input);
|
|
208
|
+
return { ...input, ...(t.terragrunt ? { terragrunt: t.terragrunt } : {}), ...(t.binary ? { binary: t.binary } : {}) };
|
|
209
|
+
}
|
|
210
|
+
/** A wave's units by the pair of releases they run, the step's own pair first, each with the input its `run --all` takes. */
|
|
211
|
+
async function groupUnits(resolveUnit, input, units) {
|
|
212
|
+
const key = (i) => JSON.stringify([i.terragrunt ?? null, i.binary ?? null]);
|
|
213
|
+
const own = key(input);
|
|
214
|
+
const byKey = new Map();
|
|
215
|
+
for (const u of units) {
|
|
216
|
+
const i = await unitInput(resolveUnit, input, u);
|
|
217
|
+
const k = key(i);
|
|
218
|
+
if (!byKey.has(k))
|
|
219
|
+
byKey.set(k, { input: i, units: [] });
|
|
220
|
+
byKey.get(k).units.push(u);
|
|
221
|
+
}
|
|
222
|
+
const groups = [...byKey.entries()];
|
|
223
|
+
groups.sort(([a], [b]) => (a === own ? -1 : b === own ? 1 : 0));
|
|
224
|
+
return groups.map(([, g]) => g);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Plan each group with its own `run --all`. A group whose units would read
|
|
228
|
+
* `mock_outputs` is refused as one wave is: every group still plans, then one
|
|
229
|
+
* refusal names every read.
|
|
230
|
+
*/
|
|
231
|
+
async function planGroups(exec, groups, env) {
|
|
232
|
+
const reads = [];
|
|
233
|
+
const out = [];
|
|
234
|
+
const plans = new Map();
|
|
235
|
+
for (const g of groups) {
|
|
236
|
+
let planned;
|
|
237
|
+
try {
|
|
238
|
+
planned = await planUnits(exec, g.input, g.units, env);
|
|
239
|
+
}
|
|
240
|
+
catch (e) {
|
|
241
|
+
if (e instanceof TerragruntMockRefusal && groups.length > 1) {
|
|
242
|
+
reads.push(...e.reads);
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
throw e;
|
|
246
|
+
}
|
|
247
|
+
out.push({ units: g.units, workDir: planned.workDir, ...(g.input.terragrunt ? { terragrunt: g.input.terragrunt } : {}), ...(g.input.binary ? { binary: g.input.binary } : {}) });
|
|
248
|
+
for (const [u, p] of planned.plans)
|
|
249
|
+
plans.set(u, p);
|
|
250
|
+
}
|
|
251
|
+
if (reads.length > 0)
|
|
252
|
+
throw new TerragruntMockRefusal(reads);
|
|
253
|
+
return { groups: out, plans };
|
|
254
|
+
}
|
|
255
|
+
const isWaveArtifact = (v) => v?.kind === "terragrunt-apply" && Array.isArray(v.units);
|
|
256
|
+
const isUnitArtifact = (v) => v?.kind === "terragrunt-apply-unit";
|
|
257
|
+
/** The `terragrunt-apply` capability, with `deps` in place of the defaults. */
|
|
258
|
+
export function terragruntApplyCapability(deps = {}) {
|
|
259
|
+
const exec = deps.exec ?? defaultTerragruntExec;
|
|
260
|
+
const resolveUnit = deps.resolveUnit;
|
|
261
|
+
return {
|
|
262
|
+
kind: "terragrunt-apply",
|
|
263
|
+
rollbackPolicy: "needs-opt-out",
|
|
264
|
+
// A unit plans and applies as a whole, and Terragrunt takes each unit's own backend lock.
|
|
265
|
+
defaultLockGrain: () => "target",
|
|
266
|
+
async discoverRuns(ctx, input) {
|
|
267
|
+
const found = await discoverTerragruntUnits({
|
|
268
|
+
dir: dirOf(input),
|
|
269
|
+
exec,
|
|
270
|
+
...(input.terragrunt ? { terragrunt: input.terragrunt } : {}),
|
|
271
|
+
...(input.binary ? { binary: input.binary } : {}),
|
|
272
|
+
...(input.exclude ? { exclude: input.exclude } : {}),
|
|
273
|
+
});
|
|
274
|
+
const waves = (input.layers ? terragruntListedWaves(input.layers, found.units) : terragruntWaves(found.units, input.canary ? { canary: input.canary } : {})).filter((w) => w.length > 0);
|
|
275
|
+
return { targets: waves[ctx.wave.number - 1] ?? [], waves: waves.length };
|
|
276
|
+
},
|
|
277
|
+
async plan(ctx, input) {
|
|
278
|
+
if (typeof input.unit !== "string" || input.unit === "")
|
|
279
|
+
throw new Error("terragrunt-apply: the step names no unit");
|
|
280
|
+
await ctx.afterInit?.();
|
|
281
|
+
const { plans } = await planUnits(exec, await unitInput(resolveUnit, input, input.unit), [input.unit], ctx.processEnv);
|
|
282
|
+
return plans.get(input.unit);
|
|
283
|
+
},
|
|
284
|
+
async run(ctx, input) {
|
|
285
|
+
const given = ctx.plans?.[input.unit];
|
|
286
|
+
const own = await unitInput(resolveUnit, input, input.unit);
|
|
287
|
+
// A unit with no plan from the wave plans now and applies that plan.
|
|
288
|
+
const workDir = isUnitArtifact(given) ? given.workDir : (await planUnits(exec, own, [input.unit], ctx.processEnv)).workDir;
|
|
289
|
+
const applied = await applyUnits(exec, own, [input.unit], workDir, ctx.processEnv);
|
|
290
|
+
const result = applied.results.find((r) => r.unit === input.unit);
|
|
291
|
+
if (result?.status !== "succeeded")
|
|
292
|
+
throw new Error(`terragrunt-apply: ${input.unit}: ${result?.error ?? "Terragrunt did not apply it"}`);
|
|
293
|
+
return { unit: input.unit, applied: true };
|
|
294
|
+
},
|
|
295
|
+
async planGroup(_ctx, members) {
|
|
296
|
+
const { input, units, env } = shared(members);
|
|
297
|
+
for (const m of members)
|
|
298
|
+
await m.ctx.afterInit?.();
|
|
299
|
+
const { groups, plans } = await planGroups(exec, await groupUnits(resolveUnit, input, units), env);
|
|
300
|
+
const artifact = { kind: "terragrunt-apply", workDir: groups[0].workDir, units: [...units], groups };
|
|
301
|
+
// One group hashes as a wave always has; more name each group's units. Not the releases' paths, which depend on where a job installed them: each unit's plan digest covers what its release planned.
|
|
302
|
+
const digest = computePlanDigest("terragrunt-apply-wave", {
|
|
303
|
+
units: [...units].sort(),
|
|
304
|
+
destroy: input.destroy === true,
|
|
305
|
+
...(groups.length > 1 ? { groups: groups.map((g) => [...g.units].sort()).sort((a, b) => a.join("\u0000").localeCompare(b.join("\u0000"))) } : {}),
|
|
306
|
+
});
|
|
307
|
+
return { members: Object.fromEntries(members.map((m) => [m.component, plans.get(m.input?.unit ?? m.step.unit)])), digest, artifact };
|
|
308
|
+
},
|
|
309
|
+
async runGroup(_ctx, run, members) {
|
|
310
|
+
const { input, units, env } = shared(members);
|
|
311
|
+
if (!isWaveArtifact(run.artifact))
|
|
312
|
+
throw new Error("terragrunt-apply: no plan of the wave to apply");
|
|
313
|
+
const planned = new Set(run.artifact.units);
|
|
314
|
+
const unplanned = units.filter((u) => !planned.has(u));
|
|
315
|
+
if (unplanned.length > 0)
|
|
316
|
+
throw new Error(`terragrunt-apply: ${unplanned.join(", ")} ${unplanned.length === 1 ? "is" : "are"} not in the wave's plan`);
|
|
317
|
+
const want = new Set(units);
|
|
318
|
+
const groups = run.artifact.groups ?? [{ units: run.artifact.units, workDir: run.artifact.workDir, ...(input.terragrunt ? { terragrunt: input.terragrunt } : {}), ...(input.binary ? { binary: input.binary } : {}) }];
|
|
319
|
+
const grouped = new Set(groups.flatMap((g) => g.units));
|
|
320
|
+
const ungrouped = units.filter((u) => !grouped.has(u));
|
|
321
|
+
if (ungrouped.length > 0)
|
|
322
|
+
throw new Error(`terragrunt-apply: ${ungrouped.join(", ")} ${ungrouped.length === 1 ? "is" : "are"} in no group of the wave's plan`);
|
|
323
|
+
const applied = { results: [], code: 0 };
|
|
324
|
+
// Each group applies its own saved plans with its own releases.
|
|
325
|
+
for (const g of groups) {
|
|
326
|
+
const mine = g.units.filter((u) => want.has(u));
|
|
327
|
+
if (mine.length === 0)
|
|
328
|
+
continue;
|
|
329
|
+
const { terragrunt: _tg, binary: _bin, ...rest } = input;
|
|
330
|
+
const a = await applyUnits(exec, { ...rest, ...(g.terragrunt ? { terragrunt: g.terragrunt } : {}), ...(g.binary ? { binary: g.binary } : {}) }, mine, g.workDir, env);
|
|
331
|
+
applied.results.push(...a.results);
|
|
332
|
+
if (applied.code === 0)
|
|
333
|
+
applied.code = a.code;
|
|
334
|
+
}
|
|
335
|
+
const byUnit = new Map(applied.results.map((r) => [r.unit, r]));
|
|
336
|
+
const out = {};
|
|
337
|
+
for (const m of members) {
|
|
338
|
+
const unit = m.input?.unit ?? m.step.unit;
|
|
339
|
+
const r = byUnit.get(unit);
|
|
340
|
+
out[m.component] = r?.status === "succeeded" ? { status: "applied" } : { status: "failed", error: r?.error ?? "Terragrunt did not apply it" };
|
|
341
|
+
}
|
|
342
|
+
return { members: out, ...(applied.code !== 0 && applied.results.every((r) => r.status === "succeeded") ? { error: `terragrunt exited ${applied.code}` } : {}) };
|
|
343
|
+
},
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
/** `terragrunt-apply` with Terragrunt on PATH. */
|
|
347
|
+
export const terragruntApply = terragruntApplyCapability();
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Terragrunt units as roots (#3414). `./units`, `./wave` and `./mocks` are pure and
|
|
3
3
|
* bundle without TypeScript; `./run` spawns `terragrunt`. `./affected` picks
|
|
4
|
-
* the units a git range touches (#3415).
|
|
4
|
+
* the units a git range touches (#3415). `./capability` is `terragrunt-apply`,
|
|
5
|
+
* the units as an op wave's step (#4842).
|
|
5
6
|
*/
|
|
6
7
|
export * from "./units.js";
|
|
7
8
|
export * from "./wave.js";
|
|
8
9
|
export * from "./mocks.js";
|
|
9
10
|
export * from "./run.js";
|
|
10
11
|
export * from "./affected.js";
|
|
12
|
+
export * from "./capability.js";
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/terragrunt/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/terragrunt/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
package/dist/terragrunt/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Terragrunt units as roots (#3414). `./units`, `./wave` and `./mocks` are pure and
|
|
3
3
|
* bundle without TypeScript; `./run` spawns `terragrunt`. `./affected` picks
|
|
4
|
-
* the units a git range touches (#3415).
|
|
4
|
+
* the units a git range touches (#3415). `./capability` is `terragrunt-apply`,
|
|
5
|
+
* the units as an op wave's step (#4842).
|
|
5
6
|
*/
|
|
6
7
|
export * from "./units.js";
|
|
7
8
|
export * from "./wave.js";
|
|
8
9
|
export * from "./mocks.js";
|
|
9
10
|
export * from "./run.js";
|
|
10
11
|
export * from "./affected.js";
|
|
12
|
+
export * from "./capability.js";
|
|
@@ -91,6 +91,15 @@ export declare class TerragruntWaveError extends Error {
|
|
|
91
91
|
* reads.
|
|
92
92
|
*/
|
|
93
93
|
export declare function terragruntWaves(units: readonly TerragruntUnit[], options?: TerragruntWavesOptions): string[][];
|
|
94
|
+
/**
|
|
95
|
+
* The waves a pipeline lists (#4842), cut again by the graph discovery gives
|
|
96
|
+
* now: each listed wave split into its own dependency layers, the listed
|
|
97
|
+
* order kept, so canary waves listed first stay first. A pipeline written
|
|
98
|
+
* with the graph comes back as it is. A unit that depends on a unit of a
|
|
99
|
+
* later listed wave is refused, since the list is stale; units the pipeline
|
|
100
|
+
* does not list stay out. Empty layers are dropped.
|
|
101
|
+
*/
|
|
102
|
+
export declare function terragruntListedWaves(listed: readonly (readonly string[])[], units: readonly TerragruntUnit[]): string[][];
|
|
94
103
|
/**
|
|
95
104
|
* Every unit that depends on one of `changed`, directly or through other
|
|
96
105
|
* units, not counting `changed` itself. Sorted by path.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../src/terragrunt/units.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAE7D,4GAA4G;AAC5G,eAAO,MAAM,sBAAsB,UAAU,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,EAAE,SAAS,MAAM,EA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AAC;CAC5B;AAED,+EAA+E;AAC/E,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,EAAE,OAAO,GAAE,sBAA2B,GAAG,MAAM,EAAE,EAAE,CAmBlH;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,EAAE,EAAE,CAe1H;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,KAAK,GAAE,CAAC,IAAI,EAAE,cAAc,KAAK,SAAS,MAAM,EAA0B,GACzE,MAAM,EAAE,CAeV"}
|
package/dist/terragrunt/units.js
CHANGED
|
@@ -168,6 +168,31 @@ export function terragruntWaves(units, options = {}) {
|
|
|
168
168
|
};
|
|
169
169
|
return [...layer(nodes.filter((n) => canaries.has(n.name))), ...layer(nodes.filter((n) => !canaries.has(n.name)))];
|
|
170
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* The waves a pipeline lists (#4842), cut again by the graph discovery gives
|
|
173
|
+
* now: each listed wave split into its own dependency layers, the listed
|
|
174
|
+
* order kept, so canary waves listed first stay first. A pipeline written
|
|
175
|
+
* with the graph comes back as it is. A unit that depends on a unit of a
|
|
176
|
+
* later listed wave is refused, since the list is stale; units the pipeline
|
|
177
|
+
* does not list stay out. Empty layers are dropped.
|
|
178
|
+
*/
|
|
179
|
+
export function terragruntListedWaves(listed, units) {
|
|
180
|
+
const deps = new Map(units.map((u) => [u.path, u.dependencies]));
|
|
181
|
+
const waveOf = new Map();
|
|
182
|
+
listed.forEach((w, i) => w.forEach((u) => waveOf.set(u, i)));
|
|
183
|
+
const out = [];
|
|
184
|
+
listed.forEach((wave, i) => {
|
|
185
|
+
const members = new Set(wave);
|
|
186
|
+
for (const u of wave) {
|
|
187
|
+
const later = (deps.get(u) ?? []).filter((d) => (waveOf.get(d) ?? -1) > i);
|
|
188
|
+
if (later.length > 0)
|
|
189
|
+
throw new TerragruntWaveError(`${u} depends on ${later.join(", ")}, which the pipeline applies in a later wave; cut the waves again`);
|
|
190
|
+
}
|
|
191
|
+
const sub = wave.map((path) => ({ path, dependencies: (deps.get(path) ?? []).filter((d) => members.has(d)) }));
|
|
192
|
+
out.push(...terragruntWaves(sub).filter((w) => w.length > 0));
|
|
193
|
+
});
|
|
194
|
+
return out;
|
|
195
|
+
}
|
|
171
196
|
/**
|
|
172
197
|
* Every unit that depends on one of `changed`, directly or through other
|
|
173
198
|
* units, not counting `changed` itself. Sorted by path.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant-lexicon-terraform",
|
|
3
|
-
"version": "0.124.
|
|
3
|
+
"version": "0.124.79",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"src/",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"access": "public"
|
|
94
94
|
},
|
|
95
95
|
"peerDependencies": {
|
|
96
|
-
"@intentius/chant": "^0.124.
|
|
96
|
+
"@intentius/chant": "^0.124.79",
|
|
97
97
|
"zod": "^4.3.6"
|
|
98
98
|
},
|
|
99
99
|
"description": "terraform lexicon for chant, existing Terraform root modules as declarable entities",
|
package/src/change-set.test.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
20
20
|
import { join } from "node:path";
|
|
21
21
|
import { describe, expect, test } from "vitest";
|
|
22
|
-
import { composeChangeSet, type ChangeSetPart } from "@intentius/chant/change-set";
|
|
22
|
+
import { composeChangeSet, isEmptyChangeSet, type ChangeSetPart } from "@intentius/chant/change-set";
|
|
23
23
|
import { actionFor, choudoufuSetPlanParts, parseTerraformAddress, plannerForBinary, terraformChangeSetPart } from "./change-set";
|
|
24
24
|
import { terraformPlanDigest } from "./plan-digest";
|
|
25
25
|
|
|
@@ -149,3 +149,29 @@ describe("address and action parsing", () => {
|
|
|
149
149
|
expect(plannerForBinary(undefined)).toBe("terraform");
|
|
150
150
|
});
|
|
151
151
|
});
|
|
152
|
+
|
|
153
|
+
describe("a plan that changes only outputs (#4849)", () => {
|
|
154
|
+
// The recorded tofu plan's no-op resource, with output_changes as show -json gives them.
|
|
155
|
+
const keep = (read("tofu.plan.json") as { resource_changes: { address: string }[] }).resource_changes.find((r) => r.address === "terraform_data.keep")!;
|
|
156
|
+
const withOutputs = (outputs: Record<string, string[]>) => ({
|
|
157
|
+
format_version: "1.2",
|
|
158
|
+
resource_changes: [keep],
|
|
159
|
+
output_changes: Object.fromEntries(Object.entries(outputs).map(([name, actions]) => [name, { actions, before: "a", after: actions.includes("no-op") ? "a" : "b", after_unknown: false, before_sensitive: false, after_sensitive: false }])),
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test("the member names each output the plan changes, sorted, and the change set is not empty", () => {
|
|
163
|
+
const part = terraformChangeSetPart({ member: "root", plan: withOutputs({ url: ["update"], name: ["create"], kept: ["no-op"] }), planner: "tofu" });
|
|
164
|
+
expect(part.entries.map((e) => e.action)).toEqual(["no-op"]);
|
|
165
|
+
expect(part.member.outputs).toEqual(["name", "url"]);
|
|
166
|
+
expect(isEmptyChangeSet(composeChangeSet([part]))).toBe(false);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test("a plan whose outputs are all no-op, or that has none, names none, and hashes as before", () => {
|
|
170
|
+
const plain = withOutputs({ kept: ["no-op"] });
|
|
171
|
+
const part = terraformChangeSetPart({ member: "root", plan: plain, planner: "tofu" });
|
|
172
|
+
expect(part.member).not.toHaveProperty("outputs");
|
|
173
|
+
expect(isEmptyChangeSet(composeChangeSet([part]))).toBe(true);
|
|
174
|
+
expect(part.member.planDigest).toBe(terraformPlanDigest(plain));
|
|
175
|
+
expect(terraformChangeSetPart({ member: "estate", plan: read("tofu.plan.json"), planner: "tofu" }).member).not.toHaveProperty("outputs");
|
|
176
|
+
});
|
|
177
|
+
});
|
package/src/change-set.ts
CHANGED
|
@@ -152,6 +152,7 @@ export interface TerraformChangeSetPartInput {
|
|
|
152
152
|
* One terraform-family root's part, from its `show -json` plan.
|
|
153
153
|
*
|
|
154
154
|
* Every `resource_changes` entry becomes an entry, no-op and read included.
|
|
155
|
+
* The outputs `output_changes` changes are the member's `outputs`.
|
|
155
156
|
* A plan stock marked `errored` is a failed member: its entries are kept,
|
|
156
157
|
* but nothing should apply it.
|
|
157
158
|
*/
|
|
@@ -189,6 +190,7 @@ export function terraformChangeSetPart(input: TerraformChangeSetPartInput): Chan
|
|
|
189
190
|
});
|
|
190
191
|
const sideEffects = (Array.isArray(plan.action_invocations) ? plan.action_invocations : []).map(sideEffectFor);
|
|
191
192
|
const errored = plan.errored === true;
|
|
193
|
+
const outputs = changedOutputs(plan.output_changes);
|
|
192
194
|
return {
|
|
193
195
|
member: {
|
|
194
196
|
member: input.member,
|
|
@@ -199,6 +201,7 @@ export function terraformChangeSetPart(input: TerraformChangeSetPartInput): Chan
|
|
|
199
201
|
...(errored ? { error: `${planner} marked the plan errored` } : {}),
|
|
200
202
|
planDigest: terraformPlanDigest(plan),
|
|
201
203
|
...(input.nativeDigest ? { nativeDigest: input.nativeDigest } : {}),
|
|
204
|
+
...(outputs.length > 0 ? { outputs } : {}),
|
|
202
205
|
holes: [],
|
|
203
206
|
},
|
|
204
207
|
entries,
|
|
@@ -206,6 +209,22 @@ export function terraformChangeSetPart(input: TerraformChangeSetPartInput): Chan
|
|
|
206
209
|
};
|
|
207
210
|
}
|
|
208
211
|
|
|
212
|
+
/**
|
|
213
|
+
* The outputs a plan's `output_changes` changes, sorted (#4849): each whose
|
|
214
|
+
* actions are anything but `no-op`. A plan that changes only outputs is a
|
|
215
|
+
* change, as terragucci counts it.
|
|
216
|
+
*/
|
|
217
|
+
function changedOutputs(raw: unknown): string[] {
|
|
218
|
+
if (!isObject(raw)) return [];
|
|
219
|
+
return Object.entries(raw)
|
|
220
|
+
.filter(([, change]) => {
|
|
221
|
+
const actions = isObject(change) && Array.isArray(change.actions) ? change.actions : [];
|
|
222
|
+
return actions.some((a) => a !== "no-op");
|
|
223
|
+
})
|
|
224
|
+
.map(([name]) => name)
|
|
225
|
+
.sort();
|
|
226
|
+
}
|
|
227
|
+
|
|
209
228
|
/**
|
|
210
229
|
* One `action_invocations` entry of a plan (Terraform 1.14): the action's
|
|
211
230
|
* address and type, and, for a lifecycle trigger, the resource and event.
|