cdk-real-drift 0.4.36 → 0.4.38
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/cli.js +70 -14
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -8717,7 +8717,7 @@ const readAppSyncApiKey = async ({ physicalId, declared, region }) => {
|
|
|
8717
8717
|
if (k.expires !== void 0) model.Expires = k.expires;
|
|
8718
8718
|
return model;
|
|
8719
8719
|
};
|
|
8720
|
-
const readCognitoIdentityPool = async ({ physicalId, region }) => {
|
|
8720
|
+
const readCognitoIdentityPool = async ({ physicalId, declared, region }) => {
|
|
8721
8721
|
const id = str$1(physicalId);
|
|
8722
8722
|
if (!id) return void 0;
|
|
8723
8723
|
const g = await new CloudControlClient({
|
|
@@ -8734,9 +8734,25 @@ const readCognitoIdentityPool = async ({ physicalId, region }) => {
|
|
|
8734
8734
|
...READ_RETRY
|
|
8735
8735
|
}).send(new GetCognitoEventsCommand({ IdentityPoolId: id }));
|
|
8736
8736
|
if (ev.Events && Object.keys(ev.Events).length > 0) model.CognitoEvents = ev.Events;
|
|
8737
|
-
} catch {
|
|
8737
|
+
} catch (e) {
|
|
8738
|
+
if ("CognitoEvents" in declared && !("CognitoEvents" in model)) model.CognitoEvents = declared.CognitoEvents;
|
|
8739
|
+
if (!isCognitoSyncRegionUnavailable(e)) {
|
|
8740
|
+
const call = e?.name || "unknown error";
|
|
8741
|
+
const gap = "CognitoEvents" in declared ? " — treating CognitoEvents as an unverifiable read-gap (declared value assumed unchanged; grant cognito-sync:GetCognitoEvents to detect out-of-band drift on it)" : "";
|
|
8742
|
+
process.stderr.write(`[cdkrd] warning: cognito-sync:GetCognitoEvents for ${id} failed (${call})${gap}\n`);
|
|
8743
|
+
}
|
|
8744
|
+
}
|
|
8738
8745
|
return model;
|
|
8739
8746
|
};
|
|
8747
|
+
function isCognitoSyncRegionUnavailable(err) {
|
|
8748
|
+
if (isDefinitiveDenial(err)) return false;
|
|
8749
|
+
const e = err;
|
|
8750
|
+
if (!e) return false;
|
|
8751
|
+
const regionUnavailable = /^(UnknownEndpoint|EndpointError|InvalidEndpoint)$/;
|
|
8752
|
+
if (e.name && regionUnavailable.test(e.name)) return true;
|
|
8753
|
+
if (e.code && (regionUnavailable.test(e.code) || e.code === "ENOTFOUND")) return true;
|
|
8754
|
+
return e.cause?.code === "ENOTFOUND" || e.cause?.errno === "ENOTFOUND";
|
|
8755
|
+
}
|
|
8740
8756
|
const readSesReceiptRuleSet = async ({ physicalId, declared, region }) => {
|
|
8741
8757
|
const name = str$1(physicalId) ?? str$1(declared.RuleSetName);
|
|
8742
8758
|
if (!name) return void 0;
|
|
@@ -10582,7 +10598,31 @@ function splitRecordedByBaseline(recorded, baseline) {
|
|
|
10582
10598
|
function selectRecorded(findings, selectedKeys) {
|
|
10583
10599
|
return buildRecorded(findings).filter((e) => selectedKeys.has(recordedKey(e)));
|
|
10584
10600
|
}
|
|
10585
|
-
|
|
10601
|
+
function pathSegments$1(path) {
|
|
10602
|
+
return path.replace(/\[([^\]]*)\]/g, ".$1").split(".").filter((s) => s.length > 0);
|
|
10603
|
+
}
|
|
10604
|
+
function descendDeclared(node, seg) {
|
|
10605
|
+
if (node === null || typeof node !== "object") return void 0;
|
|
10606
|
+
if (Array.isArray(node)) {
|
|
10607
|
+
for (const el of node) if (el !== null && typeof el === "object" && !Array.isArray(el)) {
|
|
10608
|
+
for (const idf of DELTA_IDENTITY_FIELDS) if (String(el[idf]) === seg) return el;
|
|
10609
|
+
}
|
|
10610
|
+
const idx = Number(seg);
|
|
10611
|
+
return Number.isInteger(idx) && idx >= 0 && idx < node.length ? node[idx] : void 0;
|
|
10612
|
+
}
|
|
10613
|
+
return node[seg];
|
|
10614
|
+
}
|
|
10615
|
+
function declaredPathIsPromoted(declared, path) {
|
|
10616
|
+
if (declared === void 0) return false;
|
|
10617
|
+
let node = declared;
|
|
10618
|
+
for (const seg of pathSegments$1(path)) {
|
|
10619
|
+
if (node === null || typeof node !== "object") return true;
|
|
10620
|
+
const next = descendDeclared(node, seg);
|
|
10621
|
+
if (next === void 0) return false;
|
|
10622
|
+
node = next;
|
|
10623
|
+
}
|
|
10624
|
+
return true;
|
|
10625
|
+
}
|
|
10586
10626
|
/**
|
|
10587
10627
|
* Reconcile undeclared findings against the recorded baseline (per ENTRY, R62):
|
|
10588
10628
|
* - an undeclared finding matching an recorded entry (same value) is suppressed;
|
|
@@ -10708,7 +10748,7 @@ function applyBaseline(findings, baseline, opts = {}) {
|
|
|
10708
10748
|
removedFromTemplate.push(`${a.logicalId}.${a.path}`);
|
|
10709
10749
|
continue;
|
|
10710
10750
|
}
|
|
10711
|
-
if (
|
|
10751
|
+
if (declaredPathIsPromoted(opts.declaredByLogical?.get(a.logicalId), a.path)) {
|
|
10712
10752
|
promotedStale.push(`${a.logicalId}.${a.path}`);
|
|
10713
10753
|
continue;
|
|
10714
10754
|
}
|
|
@@ -10767,9 +10807,16 @@ function formatTypeMismatchStaleNote(paths) {
|
|
|
10767
10807
|
const n = paths.length;
|
|
10768
10808
|
return `note: ${n === 1 ? `baseline entry (${paths[0]}) was` : `${n} baseline entries were`} recorded against a resource whose logicalId now has a DIFFERENT type — re-run \`cdkrd record\`.`;
|
|
10769
10809
|
}
|
|
10770
|
-
/**
|
|
10810
|
+
/**
|
|
10811
|
+
* logicalId -> the resource's declared model, for applyBaseline's promotion check.
|
|
10812
|
+
* #1079: carries the WHOLE declared object (not just its top-level key set) so a NESTED
|
|
10813
|
+
* recorded path the user later declares is RESOLVED against the declared tree and folded
|
|
10814
|
+
* as promoted-to-code, rather than surfacing a false "removed since record". The map
|
|
10815
|
+
* feeds ApplyBaselineOptions.declaredByLogical; `applyBaseline` walks it per recorded path
|
|
10816
|
+
* via `declaredPathIsPromoted`.
|
|
10817
|
+
*/
|
|
10771
10818
|
function declaredKeysByLogical(resources) {
|
|
10772
|
-
return new Map(resources.map((r) => [r.logicalId,
|
|
10819
|
+
return new Map(resources.map((r) => [r.logicalId, r.declared]));
|
|
10773
10820
|
}
|
|
10774
10821
|
function constructPathsByLogical(resources) {
|
|
10775
10822
|
const m = /* @__PURE__ */ new Map();
|
|
@@ -13798,26 +13845,32 @@ async function revertStack(p) {
|
|
|
13798
13845
|
if (plan.items.length === 0) {
|
|
13799
13846
|
const dc = driftCount(drifted);
|
|
13800
13847
|
const uc = unrecordedCount(drifted);
|
|
13801
|
-
const
|
|
13802
|
-
out("\n" + style.drift(
|
|
13848
|
+
const reason = `nothing revertable — ${[...dc > 0 ? [`${dc} drift(s)`] : [], ...uc > 0 ? [`${uc} unrecorded value(s)`] : []].join(" + ")} remain.`;
|
|
13849
|
+
out("\n" + style.drift(reason));
|
|
13803
13850
|
return {
|
|
13804
13851
|
exit: 1,
|
|
13805
|
-
aborted: false
|
|
13852
|
+
aborted: false,
|
|
13853
|
+
refusedReason: reason
|
|
13806
13854
|
};
|
|
13807
13855
|
}
|
|
13808
13856
|
if (dryRun) {
|
|
13809
|
-
|
|
13857
|
+
const opCount = plan.items.reduce((n, i) => n + i.ops.length, 0);
|
|
13858
|
+
out(`\n(dry-run) would apply ${opCount} op(s) to ${plan.items.length} resource(s). No changes made.`);
|
|
13810
13859
|
return {
|
|
13811
13860
|
exit: 0,
|
|
13812
|
-
aborted: false
|
|
13861
|
+
aborted: false,
|
|
13862
|
+
plannedOps: opCount,
|
|
13863
|
+
plannedResources: plan.items.length
|
|
13813
13864
|
};
|
|
13814
13865
|
}
|
|
13815
13866
|
if (!yes) {
|
|
13816
13867
|
if (!interactive) {
|
|
13817
|
-
|
|
13868
|
+
const reason = "refusing to write to AWS non-interactively — pass --yes to apply (or --dry-run to preview).";
|
|
13869
|
+
console.error("\nrefusing to write to AWS non-interactively — pass --yes to apply (or --dry-run to preview).");
|
|
13818
13870
|
return {
|
|
13819
13871
|
exit: 2,
|
|
13820
|
-
aborted: false
|
|
13872
|
+
aborted: false,
|
|
13873
|
+
refusedReason: reason
|
|
13821
13874
|
};
|
|
13822
13875
|
}
|
|
13823
13876
|
if (!autoSelectAll) {
|
|
@@ -15517,7 +15570,10 @@ async function runRevert(args) {
|
|
|
15517
15570
|
reverted: outcome.reverted ?? 0,
|
|
15518
15571
|
failed: outcome.failed ?? 0,
|
|
15519
15572
|
aborted: outcome.aborted,
|
|
15520
|
-
exit: outcome.exit
|
|
15573
|
+
exit: outcome.exit,
|
|
15574
|
+
...outcome.plannedOps !== void 0 && { plannedOps: outcome.plannedOps },
|
|
15575
|
+
...outcome.plannedResources !== void 0 && { plannedResources: outcome.plannedResources },
|
|
15576
|
+
...outcome.refusedReason !== void 0 && { refusedReason: outcome.refusedReason }
|
|
15521
15577
|
});
|
|
15522
15578
|
} catch (e) {
|
|
15523
15579
|
if (isStackNotDeployed(e)) {
|