cdk-real-drift 0.12.13 → 0.12.14
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 +39 -3
- 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;
|
|
@@ -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),
|