cdk-real-drift 0.12.12 → 0.12.13

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 CHANGED
@@ -4444,8 +4444,6 @@ 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;
4449
4447
  const stackParams = {};
4450
4448
  for (const p of stack?.Parameters ?? []) {
4451
4449
  if (!p.ParameterKey) continue;
@@ -4512,7 +4510,6 @@ async function loadDesired(client, stackName, region, templateOverride, recovery
4512
4510
  region,
4513
4511
  accountId,
4514
4512
  resources,
4515
- stackTags,
4516
4513
  rawTemplate,
4517
4514
  ctx,
4518
4515
  stackStatusWarning
@@ -5014,36 +5011,6 @@ function canonicalizeBaselineForCompare(v, resourceType) {
5014
5011
  return sortObjectArraysDeep(canonicalizeForCompare(stripAwsTagsDeep(stripCcApiAwsManagedFields(v)), resourceType));
5015
5012
  }
5016
5013
 
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
-
5047
5014
  //#endregion
5048
5015
  //#region src/diff/drift-calculator.ts
5049
5016
  function calculateResourceDrift(stateProperties, awsProperties, options) {
@@ -5676,6 +5643,24 @@ function resolveParentObject(root, dottedPath) {
5676
5643
  }
5677
5644
  return node;
5678
5645
  }
5646
+ const GETTEMPLATE_MASK_NOTE = "declared value unverifiable — CloudFormation GetTemplate masks non-ASCII characters as \"?\"";
5647
+ function pushDeclaredFinding(findings, finding) {
5648
+ if (!deepEqual(finding.desired, finding.actual) && deepEqualModuloNonAsciiMask(finding.desired, finding.actual)) {
5649
+ findings.push({
5650
+ tier: "readGap",
5651
+ logicalId: finding.logicalId,
5652
+ resourceType: finding.resourceType,
5653
+ path: finding.path,
5654
+ ...finding.attributeKey !== void 0 ? { attributeKey: finding.attributeKey } : {},
5655
+ note: GETTEMPLATE_MASK_NOTE
5656
+ });
5657
+ return;
5658
+ }
5659
+ findings.push({
5660
+ tier: "declared",
5661
+ ...finding
5662
+ });
5663
+ }
5679
5664
  function classifyResource(resource, liveRaw, schema, opts = {}) {
5680
5665
  const { logicalId, resourceType, physicalId, declared: declaredIn } = resource;
5681
5666
  const findings = [];
@@ -5683,10 +5668,10 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
5683
5668
  const liveForCompare = structuredClone(liveRaw);
5684
5669
  const declaredForCompare = cloneDeepWithSymbols(declaredIn);
5685
5670
  stripAsymmetricIdentityFields(declaredForCompare, liveForCompare);
5686
- const live = subtractPropagatedStackTags(normalizeLiveModel(liveForCompare, schema, {
5671
+ const live = normalizeLiveModel(liveForCompare, schema, {
5687
5672
  oaiCanonicalIds: oaiMap,
5688
5673
  resourceType
5689
- }), opts.stackTags ?? {}, declaredTagKeys(declaredForCompare));
5674
+ });
5690
5675
  const declared = canonicalizeForCompare(rewriteOaiPrincipalsDeep(declaredForCompare, oaiMap), resourceType);
5691
5676
  const reflected = REFLECTED_CHILD_PROPS[resourceType];
5692
5677
  if (reflected && !(reflected in declared)) delete live[reflected];
@@ -6051,8 +6036,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6051
6036
  }
6052
6037
  const isNonEmptyCollection = Array.isArray(v) && v.length > 0 || v !== null && typeof v === "object" && Object.keys(v).length > 0;
6053
6038
  const isClearedAllowlistedScalar = SCALAR_RETURNED_WHEN_SET[resourceType]?.has(k) === true && (typeof v === "string" && v.length > 0 || typeof v === "number" || typeof v === "boolean");
6054
- if (isNonEmptyCollection && !READGAP_COLLECTION_PATHS[resourceType]?.has(k) || isClearedAllowlistedScalar) findings.push({
6055
- tier: "declared",
6039
+ if (isNonEmptyCollection && !READGAP_COLLECTION_PATHS[resourceType]?.has(k) || isClearedAllowlistedScalar) pushDeclaredFinding(findings, {
6056
6040
  logicalId,
6057
6041
  resourceType,
6058
6042
  path: k,
@@ -6084,12 +6068,11 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6084
6068
  logicalId,
6085
6069
  resourceType,
6086
6070
  path: k,
6087
- note: "declared value unverifiable — CloudFormation GetTemplate masks non-ASCII characters as \"?\""
6071
+ note: GETTEMPLATE_MASK_NOTE
6088
6072
  });
6089
6073
  continue;
6090
6074
  }
6091
- findings.push({
6092
- tier: "declared",
6075
+ pushDeclaredFinding(findings, {
6093
6076
  logicalId,
6094
6077
  resourceType,
6095
6078
  path: k,
@@ -6122,12 +6105,11 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6122
6105
  logicalId,
6123
6106
  resourceType,
6124
6107
  path: k,
6125
- note: "declared value unverifiable — CloudFormation GetTemplate masks non-ASCII characters as \"?\""
6108
+ note: GETTEMPLATE_MASK_NOTE
6126
6109
  });
6127
6110
  continue;
6128
6111
  }
6129
- findings.push({
6130
- tier: "declared",
6112
+ pushDeclaredFinding(findings, {
6131
6113
  logicalId,
6132
6114
  resourceType,
6133
6115
  path: k,
@@ -6146,8 +6128,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6146
6128
  if (typeof member !== "string" && typeof member !== "number") continue;
6147
6129
  declaredSet.add(String(member));
6148
6130
  if (liveSet.has(String(member))) continue;
6149
- findings.push({
6150
- tier: "declared",
6131
+ pushDeclaredFinding(findings, {
6151
6132
  logicalId,
6152
6133
  resourceType,
6153
6134
  path: k,
@@ -6180,8 +6161,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6180
6161
  const liveValue = lEl ? lEl.Value : void 0;
6181
6162
  if (deepEqual(dEl.Value, liveValue)) continue;
6182
6163
  if (isStringlyEqualScalar(dEl.Value, liveValue)) continue;
6183
- findings.push({
6184
- tier: "declared",
6164
+ pushDeclaredFinding(findings, {
6185
6165
  logicalId,
6186
6166
  resourceType,
6187
6167
  path: k,
@@ -6347,7 +6327,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6347
6327
  logicalId,
6348
6328
  resourceType,
6349
6329
  path: d.path,
6350
- note: "declared value unverifiable — CloudFormation GetTemplate masks non-ASCII characters as \"?\""
6330
+ note: GETTEMPLATE_MASK_NOTE
6351
6331
  });
6352
6332
  continue;
6353
6333
  }
@@ -6379,8 +6359,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6379
6359
  path: k,
6380
6360
  value: v
6381
6361
  } } : {};
6382
- findings.push({
6383
- tier: "declared",
6362
+ pushDeclaredFinding(findings, {
6384
6363
  logicalId,
6385
6364
  resourceType,
6386
6365
  path: d.path,
@@ -11719,7 +11698,6 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
11719
11698
  region,
11720
11699
  kmsAliasTargets,
11721
11700
  defaultSgIds,
11722
- stackTags: desired.stackTags,
11723
11701
  oaiCanonicalIds,
11724
11702
  siblingSgRules: buildSiblingSgRules(desired),
11725
11703
  siblingEventBusPolicies: buildSiblingEventBusPolicies(desired),
@@ -11789,7 +11767,6 @@ async function regatherTouched(gathered, touched, region) {
11789
11767
  region,
11790
11768
  kmsAliasTargets,
11791
11769
  defaultSgIds,
11792
- stackTags: desired.stackTags,
11793
11770
  oaiCanonicalIds,
11794
11771
  siblingSgRules: buildSiblingSgRules(desired),
11795
11772
  siblingEventBusPolicies: buildSiblingEventBusPolicies(desired),