cdk-real-drift 0.4.27 → 0.4.29
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 +41 -6
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -10113,6 +10113,23 @@ function stackCountAnnouncement(stackNames) {
|
|
|
10113
10113
|
|
|
10114
10114
|
//#endregion
|
|
10115
10115
|
//#region src/baseline/baseline-file.ts
|
|
10116
|
+
const KNOWN_BASELINE_KEYS = new Set([
|
|
10117
|
+
"schemaVersion",
|
|
10118
|
+
"stackName",
|
|
10119
|
+
"region",
|
|
10120
|
+
"accountId",
|
|
10121
|
+
"capturedAt",
|
|
10122
|
+
"templateHash",
|
|
10123
|
+
"recorded",
|
|
10124
|
+
"completeResources",
|
|
10125
|
+
"recordedPhysicalIds"
|
|
10126
|
+
]);
|
|
10127
|
+
const KNOWN_RECORDED_ENTRY_KEYS = new Set([
|
|
10128
|
+
"logicalId",
|
|
10129
|
+
"resourceType",
|
|
10130
|
+
"path",
|
|
10131
|
+
"value"
|
|
10132
|
+
]);
|
|
10116
10133
|
function baselinePath(stackName, accountId, region) {
|
|
10117
10134
|
return `.cdkrd/baselines/${stackName}.${accountId}.${region}.json`;
|
|
10118
10135
|
}
|
|
@@ -10131,8 +10148,10 @@ async function loadBaseline(stackName, accountId, region) {
|
|
|
10131
10148
|
let parsed;
|
|
10132
10149
|
try {
|
|
10133
10150
|
parsed = JSON.parse(raw);
|
|
10134
|
-
} catch {
|
|
10135
|
-
|
|
10151
|
+
} catch (e) {
|
|
10152
|
+
const detail = e.message;
|
|
10153
|
+
const conflict = /^(<{7}|={7}|>{7})/m.test(raw) ? " — looks like an unresolved git merge conflict (resolve the <<<<<<< / ======= / >>>>>>> markers)" : "";
|
|
10154
|
+
throw new Error(`baseline file ${path} is not valid JSON (corrupt or partially written): ${detail}${conflict} (delete or \`git restore\` the file to reset, then re-run \`cdkrd record\`)`);
|
|
10136
10155
|
}
|
|
10137
10156
|
if (parsed === null || typeof parsed !== "object") throw new Error(`baseline file ${path} is malformed: root is not an object`);
|
|
10138
10157
|
if (parsed.stackName && parsed.stackName !== stackName) throw new Error(`baseline file ${path} was captured for stack ${parsed.stackName}, but it was loaded as stack ${stackName} (the file was likely copied or renamed to the wrong path, or a case-insensitive filesystem collided two stacks onto one file). Baselines are per-stack — run \`cdkrd record\` to write this stack's own baseline file, or restore the correct file from git.`);
|
|
@@ -10142,6 +10161,8 @@ async function loadBaseline(stackName, accountId, region) {
|
|
|
10142
10161
|
if (parsed.schemaVersion !== void 0 && typeof parsed.schemaVersion !== "number") throw new Error(`baseline file ${path} has a non-numeric schemaVersion (${JSON.stringify(parsed.schemaVersion)}); it is malformed (corrupt or hand-edited)`);
|
|
10143
10162
|
if (typeof parsed.schemaVersion === "number" && parsed.schemaVersion > 2) throw new Error(`baseline file ${path} was written by a newer cdkrd (schemaVersion ${parsed.schemaVersion}); upgrade cdkrd`);
|
|
10144
10163
|
if (!Array.isArray(parsed.recorded)) throw new Error(`baseline file ${path} is malformed: \`recorded\` is missing or not an array`);
|
|
10164
|
+
const unknownTop = Object.keys(parsed).filter((k) => !KNOWN_BASELINE_KEYS.has(k));
|
|
10165
|
+
if (unknownTop.length > 0) throw new Error(`baseline file ${path}: unknown key(s) ${unknownTop.map((k) => `"${k}"`).join(", ")} — known keys: ${[...KNOWN_BASELINE_KEYS].map((k) => `"${k}"`).join(", ")} (a typo silently disables detection; correct or remove it)`);
|
|
10145
10166
|
parsed.recorded.forEach((entry, i) => validateRecordedEntry(entry, i, path));
|
|
10146
10167
|
validateRecordedUniqueness(parsed.recorded, path);
|
|
10147
10168
|
validateCompleteResources(parsed.completeResources, path);
|
|
@@ -10166,6 +10187,9 @@ function validateRecordedEntry(entry, index, path) {
|
|
|
10166
10187
|
"resourceType",
|
|
10167
10188
|
"path"
|
|
10168
10189
|
]) if (typeof obj[k] !== "string") throw new Error(`${at}: "${k}" is required and must be a string`);
|
|
10190
|
+
const unknown = Object.keys(obj).filter((k) => !KNOWN_RECORDED_ENTRY_KEYS.has(k));
|
|
10191
|
+
if (unknown.length > 0) throw new Error(`${at}: unknown key(s) ${unknown.map((k) => `"${k}"`).join(", ")} — known keys: "logicalId", "resourceType", "path", "value" (a typo'd "value" false-flags confirmed drift)`);
|
|
10192
|
+
if (!("value" in obj)) throw new Error(`${at}: "value" is required (use null for an empty value)`);
|
|
10169
10193
|
}
|
|
10170
10194
|
/**
|
|
10171
10195
|
* #1047: reject duplicate `recorded` identity keys at load. The baseline is git-committed,
|
|
@@ -11781,26 +11805,37 @@ const writeDaxCluster = async (ctx, ops) => {
|
|
|
11781
11805
|
const writeDaxParameterGroup = async (ctx, ops) => {
|
|
11782
11806
|
const name = str(ctx.physicalId) ?? str(ctx.declared["ParameterGroupName"]);
|
|
11783
11807
|
if (!name) throw new Error("cannot resolve DAX parameter-group name for revert");
|
|
11784
|
-
const
|
|
11808
|
+
const reader = SDK_OVERRIDES["AWS::DAX::ParameterGroup"];
|
|
11809
|
+
const live = (reader && await reader(ctx)) ?? {};
|
|
11810
|
+
const liveValues = live.ParameterNameValues ?? {};
|
|
11811
|
+
const desiredValues = applyOps(live, ops).ParameterNameValues ?? {};
|
|
11785
11812
|
const keys = /* @__PURE__ */ new Set();
|
|
11813
|
+
const unExpressible = /* @__PURE__ */ new Set();
|
|
11786
11814
|
for (const op of ops) {
|
|
11787
11815
|
const segs = op.path.replace(/^\//, "").split("/");
|
|
11788
11816
|
if (segs[0] !== "ParameterNameValues") continue;
|
|
11789
|
-
if (segs[1] !== void 0)
|
|
11817
|
+
if (segs[1] !== void 0) {
|
|
11818
|
+
const key = segs[1].replace(/~1/g, "/").replace(/~0/g, "~");
|
|
11819
|
+
if (op.op === "remove") unExpressible.add(key);
|
|
11820
|
+
else keys.add(key);
|
|
11821
|
+
} else if (op.op === "remove") for (const k of Object.keys(liveValues)) unExpressible.add(k);
|
|
11790
11822
|
else for (const k of Object.keys(desiredValues)) keys.add(k);
|
|
11791
11823
|
}
|
|
11792
11824
|
const values = [...keys].filter((k) => typeof desiredValues[k] === "string").map((k) => ({
|
|
11793
11825
|
ParameterName: k,
|
|
11794
11826
|
ParameterValue: desiredValues[k]
|
|
11795
11827
|
}));
|
|
11796
|
-
if (values.length
|
|
11797
|
-
await new DAXClient({
|
|
11828
|
+
if (values.length > 0) await new DAXClient({
|
|
11798
11829
|
region: ctx.region,
|
|
11799
11830
|
...CLIENT_TIMEOUTS
|
|
11800
11831
|
}).send(new UpdateParameterGroupCommand({
|
|
11801
11832
|
ParameterGroupName: name,
|
|
11802
11833
|
ParameterNameValues: values
|
|
11803
11834
|
}));
|
|
11835
|
+
if (unExpressible.size > 0) {
|
|
11836
|
+
const names = [...unExpressible].join(", ");
|
|
11837
|
+
throw new Error(`DAX ParameterGroup parameter ${names} cannot be cleared via UpdateParameterGroup (DAX has no ResetParameterGroup API, so an out-of-band-added parameter's unset state is not expressible)${values.length > 0 ? "; the other revert op(s) were applied" : ""}; update ${unExpressible.size > 1 ? "them" : "it"} manually`);
|
|
11838
|
+
}
|
|
11804
11839
|
};
|
|
11805
11840
|
const writeElastiCacheParameterGroup = async (ctx, ops) => {
|
|
11806
11841
|
const name = str(ctx.physicalId) ?? str(ctx.declared["CacheParameterGroupName"]);
|