cdk-real-drift 0.12.13 → 0.12.15
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/README.md +1 -1
- package/dist/cli.js +48 -6
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -576,7 +576,7 @@ that folds everything informational.
|
|
|
576
576
|
result: 1 drift(s) (declared=1)
|
|
577
577
|
───────────────────────────────
|
|
578
578
|
info:
|
|
579
|
-
- readGap=1 (declared but unverifiable —
|
|
579
|
+
- readGap=1 (declared but unverifiable — not drift: 1 write-only)
|
|
580
580
|
- skipped=2 (custom resource 2)
|
|
581
581
|
run with --verbose for the list
|
|
582
582
|
```
|
package/dist/cli.js
CHANGED
|
@@ -4444,6 +4444,8 @@ async function loadDesired(client, stackName, region, templateOverride, recovery
|
|
|
4444
4444
|
const rawTemplate = templateOverride ? JSON.stringify(templateOverride) : tmplRes.TemplateBody ?? "{}";
|
|
4445
4445
|
const stackId = stack?.StackId ?? "";
|
|
4446
4446
|
const accountId = stackId.split(":")[4] ?? "";
|
|
4447
|
+
const stackTags = {};
|
|
4448
|
+
for (const t of stack?.Tags ?? []) if (typeof t.Key === "string" && typeof t.Value === "string") stackTags[t.Key] = t.Value;
|
|
4447
4449
|
const stackParams = {};
|
|
4448
4450
|
for (const p of stack?.Parameters ?? []) {
|
|
4449
4451
|
if (!p.ParameterKey) continue;
|
|
@@ -4505,7 +4507,7 @@ async function loadDesired(client, stackName, region, templateOverride, recovery
|
|
|
4505
4507
|
hasSiblingCapacityProviders: res.Type === "AWS::ECS::Cluster" ? clustersWithSiblingCapacityProviders.has(logicalId) : void 0
|
|
4506
4508
|
});
|
|
4507
4509
|
}
|
|
4508
|
-
|
|
4510
|
+
const desired = {
|
|
4509
4511
|
stackName,
|
|
4510
4512
|
region,
|
|
4511
4513
|
accountId,
|
|
@@ -4514,6 +4516,8 @@ async function loadDesired(client, stackName, region, templateOverride, recovery
|
|
|
4514
4516
|
ctx,
|
|
4515
4517
|
stackStatusWarning
|
|
4516
4518
|
};
|
|
4519
|
+
desired.stackTags = stackTags;
|
|
4520
|
+
return desired;
|
|
4517
4521
|
}
|
|
4518
4522
|
const IAM_PRINCIPAL_TYPES = new Set([
|
|
4519
4523
|
"AWS::IAM::Role",
|
|
@@ -5011,6 +5015,36 @@ function canonicalizeBaselineForCompare(v, resourceType) {
|
|
|
5011
5015
|
return sortObjectArraysDeep(canonicalizeForCompare(stripAwsTagsDeep(stripCcApiAwsManagedFields(v)), resourceType));
|
|
5012
5016
|
}
|
|
5013
5017
|
|
|
5018
|
+
//#endregion
|
|
5019
|
+
//#region src/normalize/stack-tags.ts
|
|
5020
|
+
const declaredTagKeys = (declared) => {
|
|
5021
|
+
const out = /* @__PURE__ */ new Set();
|
|
5022
|
+
const tags = declared?.Tags;
|
|
5023
|
+
if (Array.isArray(tags)) for (const t of tags) {
|
|
5024
|
+
const k = t?.Key;
|
|
5025
|
+
if (typeof k === "string") out.add(k);
|
|
5026
|
+
}
|
|
5027
|
+
return out;
|
|
5028
|
+
};
|
|
5029
|
+
const subtractPropagatedStackTags = (live, stackTags, declaredKeys) => {
|
|
5030
|
+
if (Object.keys(stackTags).length === 0) return live;
|
|
5031
|
+
const tags = live.Tags;
|
|
5032
|
+
if (!Array.isArray(tags)) return live;
|
|
5033
|
+
const filtered = tags.filter((t) => {
|
|
5034
|
+
if (!t || typeof t !== "object") return true;
|
|
5035
|
+
const key = t.Key;
|
|
5036
|
+
const value = t.Value;
|
|
5037
|
+
if (typeof key !== "string") return true;
|
|
5038
|
+
if (declaredKeys.has(key)) return true;
|
|
5039
|
+
return !(key in stackTags && stackTags[key] === value);
|
|
5040
|
+
});
|
|
5041
|
+
if (filtered.length === tags.length) return live;
|
|
5042
|
+
return {
|
|
5043
|
+
...live,
|
|
5044
|
+
Tags: filtered
|
|
5045
|
+
};
|
|
5046
|
+
};
|
|
5047
|
+
|
|
5014
5048
|
//#endregion
|
|
5015
5049
|
//#region src/diff/drift-calculator.ts
|
|
5016
5050
|
function calculateResourceDrift(stateProperties, awsProperties, options) {
|
|
@@ -5668,10 +5702,10 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
5668
5702
|
const liveForCompare = structuredClone(liveRaw);
|
|
5669
5703
|
const declaredForCompare = cloneDeepWithSymbols(declaredIn);
|
|
5670
5704
|
stripAsymmetricIdentityFields(declaredForCompare, liveForCompare);
|
|
5671
|
-
const live = normalizeLiveModel(liveForCompare, schema, {
|
|
5705
|
+
const live = subtractPropagatedStackTags(normalizeLiveModel(liveForCompare, schema, {
|
|
5672
5706
|
oaiCanonicalIds: oaiMap,
|
|
5673
5707
|
resourceType
|
|
5674
|
-
});
|
|
5708
|
+
}), opts.stackTags ?? {}, declaredTagKeys(declaredForCompare));
|
|
5675
5709
|
const declared = canonicalizeForCompare(rewriteOaiPrincipalsDeep(declaredForCompare, oaiMap), resourceType);
|
|
5676
5710
|
const reflected = REFLECTED_CHILD_PROPS[resourceType];
|
|
5677
5711
|
if (reflected && !(reflected in declared)) delete live[reflected];
|
|
@@ -11697,6 +11731,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
11697
11731
|
accountId: desired.accountId,
|
|
11698
11732
|
region,
|
|
11699
11733
|
kmsAliasTargets,
|
|
11734
|
+
stackTags: desired.stackTags ?? {},
|
|
11700
11735
|
defaultSgIds,
|
|
11701
11736
|
oaiCanonicalIds,
|
|
11702
11737
|
siblingSgRules: buildSiblingSgRules(desired),
|
|
@@ -11766,6 +11801,7 @@ async function regatherTouched(gathered, touched, region) {
|
|
|
11766
11801
|
accountId: desired.accountId,
|
|
11767
11802
|
region,
|
|
11768
11803
|
kmsAliasTargets,
|
|
11804
|
+
stackTags: desired.stackTags ?? {},
|
|
11769
11805
|
defaultSgIds,
|
|
11770
11806
|
oaiCanonicalIds,
|
|
11771
11807
|
siblingSgRules: buildSiblingSgRules(desired),
|
|
@@ -16729,6 +16765,7 @@ function reasonKey(f) {
|
|
|
16729
16765
|
const n = f.note ?? "";
|
|
16730
16766
|
if (f.tier === "ignored") return n.replace(/^ignored by config rule /, "") || "ignored";
|
|
16731
16767
|
if (f.tier === "unresolved") return "intrinsic unresolved";
|
|
16768
|
+
if (n === "declared value unverifiable — CloudFormation GetTemplate masks non-ASCII characters as \"?\"") return "non-ASCII masked by GetTemplate";
|
|
16732
16769
|
if (n.includes("write-only")) return "write-only";
|
|
16733
16770
|
if (n.startsWith("custom resource")) return "custom resource";
|
|
16734
16771
|
if (n.includes("target not resolvable")) return "override target unresolved";
|
|
@@ -16822,9 +16859,14 @@ function report(rawFindings, header, opts = {}) {
|
|
|
16822
16859
|
if (t === "generated") return `generated=${items.length} (auto-generated identifiers not in your template, AWS-assigned at deploy — not drift)`;
|
|
16823
16860
|
if (t === "readGap") {
|
|
16824
16861
|
const writeOnly = items.filter((f) => (f.note ?? "").includes("write-only")).length;
|
|
16825
|
-
const
|
|
16826
|
-
const
|
|
16827
|
-
|
|
16862
|
+
const masked = items.filter((f) => f.note === GETTEMPLATE_MASK_NOTE).length;
|
|
16863
|
+
const notReturned = items.length - writeOnly - masked;
|
|
16864
|
+
const parts = [
|
|
16865
|
+
...notReturned > 0 ? [`${notReturned} not returned by AWS`] : [],
|
|
16866
|
+
...writeOnly > 0 ? [`${writeOnly} write-only`] : [],
|
|
16867
|
+
...masked > 0 ? [`${masked} non-ASCII masked by GetTemplate`] : []
|
|
16868
|
+
];
|
|
16869
|
+
return `readGap=${items.length} (declared but unverifiable — not drift: ${parts.join(", ")})`;
|
|
16828
16870
|
}
|
|
16829
16871
|
if (t === "unresolved") return `unresolved=${items.length} (declared values whose CloudFormation intrinsic cdkrd couldn't resolve to a concrete value — e.g. Fn::GetAZs, a {{resolve:...}} dynamic reference, or an Fn::GetAtt whose target wasn't readable — unverifiable, not drift)`;
|
|
16830
16872
|
if (t === "skipped") return `skipped=${items.length} — NOT checked (coverage incomplete: ${groupReasons(items)})`;
|