cdk-real-drift 0.12.10 → 0.12.12
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 +57 -10
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
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;
|
|
@@ -4510,6 +4512,7 @@ async function loadDesired(client, stackName, region, templateOverride, recovery
|
|
|
4510
4512
|
region,
|
|
4511
4513
|
accountId,
|
|
4512
4514
|
resources,
|
|
4515
|
+
stackTags,
|
|
4513
4516
|
rawTemplate,
|
|
4514
4517
|
ctx,
|
|
4515
4518
|
stackStatusWarning
|
|
@@ -5011,6 +5014,36 @@ function canonicalizeBaselineForCompare(v, resourceType) {
|
|
|
5011
5014
|
return sortObjectArraysDeep(canonicalizeForCompare(stripAwsTagsDeep(stripCcApiAwsManagedFields(v)), resourceType));
|
|
5012
5015
|
}
|
|
5013
5016
|
|
|
5017
|
+
//#endregion
|
|
5018
|
+
//#region src/normalize/stack-tags.ts
|
|
5019
|
+
const declaredTagKeys = (declared) => {
|
|
5020
|
+
const out = /* @__PURE__ */ new Set();
|
|
5021
|
+
const tags = declared?.Tags;
|
|
5022
|
+
if (Array.isArray(tags)) for (const t of tags) {
|
|
5023
|
+
const k = t?.Key;
|
|
5024
|
+
if (typeof k === "string") out.add(k);
|
|
5025
|
+
}
|
|
5026
|
+
return out;
|
|
5027
|
+
};
|
|
5028
|
+
const subtractPropagatedStackTags = (live, stackTags, declaredKeys) => {
|
|
5029
|
+
if (Object.keys(stackTags).length === 0) return live;
|
|
5030
|
+
const tags = live.Tags;
|
|
5031
|
+
if (!Array.isArray(tags)) return live;
|
|
5032
|
+
const filtered = tags.filter((t) => {
|
|
5033
|
+
if (!t || typeof t !== "object") return true;
|
|
5034
|
+
const key = t.Key;
|
|
5035
|
+
const value = t.Value;
|
|
5036
|
+
if (typeof key !== "string") return true;
|
|
5037
|
+
if (declaredKeys.has(key)) return true;
|
|
5038
|
+
return !(key in stackTags && stackTags[key] === value);
|
|
5039
|
+
});
|
|
5040
|
+
if (filtered.length === tags.length) return live;
|
|
5041
|
+
return {
|
|
5042
|
+
...live,
|
|
5043
|
+
Tags: filtered
|
|
5044
|
+
};
|
|
5045
|
+
};
|
|
5046
|
+
|
|
5014
5047
|
//#endregion
|
|
5015
5048
|
//#region src/diff/drift-calculator.ts
|
|
5016
5049
|
function calculateResourceDrift(stateProperties, awsProperties, options) {
|
|
@@ -5650,10 +5683,10 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
5650
5683
|
const liveForCompare = structuredClone(liveRaw);
|
|
5651
5684
|
const declaredForCompare = cloneDeepWithSymbols(declaredIn);
|
|
5652
5685
|
stripAsymmetricIdentityFields(declaredForCompare, liveForCompare);
|
|
5653
|
-
const live = normalizeLiveModel(liveForCompare, schema, {
|
|
5686
|
+
const live = subtractPropagatedStackTags(normalizeLiveModel(liveForCompare, schema, {
|
|
5654
5687
|
oaiCanonicalIds: oaiMap,
|
|
5655
5688
|
resourceType
|
|
5656
|
-
});
|
|
5689
|
+
}), opts.stackTags ?? {}, declaredTagKeys(declaredForCompare));
|
|
5657
5690
|
const declared = canonicalizeForCompare(rewriteOaiPrincipalsDeep(declaredForCompare, oaiMap), resourceType);
|
|
5658
5691
|
const reflected = REFLECTED_CHILD_PROPS[resourceType];
|
|
5659
5692
|
if (reflected && !(reflected in declared)) delete live[reflected];
|
|
@@ -6082,14 +6115,26 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
6082
6115
|
};
|
|
6083
6116
|
const dv = parseJson(v);
|
|
6084
6117
|
const lv = parseJson(live[k]);
|
|
6085
|
-
if (!deepEqual(dv, lv) && !isStringlyEqualDeep(dv, lv))
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6118
|
+
if (!deepEqual(dv, lv) && !isStringlyEqualDeep(dv, lv)) {
|
|
6119
|
+
if (deepEqualModuloNonAsciiMask(dv, lv)) {
|
|
6120
|
+
findings.push({
|
|
6121
|
+
tier: "readGap",
|
|
6122
|
+
logicalId,
|
|
6123
|
+
resourceType,
|
|
6124
|
+
path: k,
|
|
6125
|
+
note: "declared value unverifiable — CloudFormation GetTemplate masks non-ASCII characters as \"?\""
|
|
6126
|
+
});
|
|
6127
|
+
continue;
|
|
6128
|
+
}
|
|
6129
|
+
findings.push({
|
|
6130
|
+
tier: "declared",
|
|
6131
|
+
logicalId,
|
|
6132
|
+
resourceType,
|
|
6133
|
+
path: k,
|
|
6134
|
+
desired: v,
|
|
6135
|
+
actual: live[k]
|
|
6136
|
+
});
|
|
6137
|
+
}
|
|
6093
6138
|
continue;
|
|
6094
6139
|
}
|
|
6095
6140
|
if (attachmentProps?.has(k) && Array.isArray(v) && Array.isArray(live[k])) {
|
|
@@ -11674,6 +11719,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
11674
11719
|
region,
|
|
11675
11720
|
kmsAliasTargets,
|
|
11676
11721
|
defaultSgIds,
|
|
11722
|
+
stackTags: desired.stackTags,
|
|
11677
11723
|
oaiCanonicalIds,
|
|
11678
11724
|
siblingSgRules: buildSiblingSgRules(desired),
|
|
11679
11725
|
siblingEventBusPolicies: buildSiblingEventBusPolicies(desired),
|
|
@@ -11743,6 +11789,7 @@ async function regatherTouched(gathered, touched, region) {
|
|
|
11743
11789
|
region,
|
|
11744
11790
|
kmsAliasTargets,
|
|
11745
11791
|
defaultSgIds,
|
|
11792
|
+
stackTags: desired.stackTags,
|
|
11746
11793
|
oaiCanonicalIds,
|
|
11747
11794
|
siblingSgRules: buildSiblingSgRules(desired),
|
|
11748
11795
|
siblingEventBusPolicies: buildSiblingEventBusPolicies(desired),
|