cdk-real-drift 0.12.20 → 0.12.21

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
@@ -11920,17 +11920,42 @@ const maskMapValues = (value) => {
11920
11920
  }
11921
11921
  return maskPlaceholder(value);
11922
11922
  };
11923
+ const maskEnvironmentContainer = (value) => {
11924
+ if (value && typeof value === "object" && !Array.isArray(value) && "Variables" in value) return {
11925
+ ...value,
11926
+ Variables: maskMapValues(value.Variables)
11927
+ };
11928
+ return value;
11929
+ };
11930
+ const maskEnvVarArrayElement = (element) => {
11931
+ if (element && typeof element === "object" && !Array.isArray(element) && "Value" in element) return {
11932
+ ...element,
11933
+ Value: maskPlaceholder(element.Value)
11934
+ };
11935
+ return element;
11936
+ };
11937
+ const maskEnvVarArray = (value) => Array.isArray(value) ? value.map(maskEnvVarArrayElement) : maskEnvVarArrayElement(value);
11923
11938
  const REDACTED_VALUE_PATHS = {
11924
- "AWS::Lambda::Function": [{
11925
- pathRe: /(^|\.)Environment\.Variables\./,
11926
- redact: maskWhole
11927
- }, {
11928
- pathRe: /(^|\.)Environment\.Variables$/,
11929
- redact: maskMapValues
11930
- }],
11939
+ "AWS::Lambda::Function": [
11940
+ {
11941
+ pathRe: /(^|\.)Environment\.Variables\./,
11942
+ redact: maskWhole
11943
+ },
11944
+ {
11945
+ pathRe: /(^|\.)Environment\.Variables$/,
11946
+ redact: maskMapValues
11947
+ },
11948
+ {
11949
+ pathRe: /(^|\.)Environment$/,
11950
+ redact: maskEnvironmentContainer
11951
+ }
11952
+ ],
11931
11953
  "AWS::CodeBuild::Project": [{
11932
11954
  pathRe: /(^|\.)Environment\.EnvironmentVariables\.\d+\.Value$/,
11933
11955
  redact: maskWhole
11956
+ }, {
11957
+ pathRe: /(^|\.)Environment\.EnvironmentVariables$/,
11958
+ redact: maskEnvVarArray
11934
11959
  }],
11935
11960
  "AWS::EC2::LaunchTemplate": [{
11936
11961
  pathRe: /(^|\.)LaunchTemplateData\.UserData$/,
@@ -12592,6 +12617,18 @@ function addedChildParentLogicalId(logicalId) {
12592
12617
  const slash = logicalId.indexOf("/");
12593
12618
  return slash < 0 ? void 0 : logicalId.slice(0, slash);
12594
12619
  }
12620
+ function addedChildIdentifier(logicalId) {
12621
+ const slash = logicalId.indexOf("/");
12622
+ return slash < 0 ? void 0 : logicalId.slice(slash + 1);
12623
+ }
12624
+ function addedChildWasAdopted(childLogicalId, physicalIdByLogical) {
12625
+ if (physicalIdByLogical === void 0 || physicalIdByLogical.size === 0) return false;
12626
+ const identifier = addedChildIdentifier(childLogicalId);
12627
+ if (identifier === void 0) return false;
12628
+ const trailing = identifier.slice(identifier.lastIndexOf("|") + 1);
12629
+ for (const livePhysicalId of physicalIdByLogical.values()) if (livePhysicalId === identifier || livePhysicalId === trailing) return true;
12630
+ return false;
12631
+ }
12595
12632
  function descendDeclared(node, seg) {
12596
12633
  if (node === null || typeof node !== "object") return void 0;
12597
12634
  if (Array.isArray(node)) {
@@ -12724,11 +12761,16 @@ function applyBaseline(findings, baseline, opts = {}) {
12724
12761
  const removedFromTemplate = [];
12725
12762
  const replacedStale = [];
12726
12763
  const typeMismatchStale = [];
12764
+ const adoptedStale = [];
12727
12765
  for (const a of recorded) {
12728
12766
  if (a.path === "") {
12729
12767
  if (presentAddedLogical.has(a.logicalId)) continue;
12730
12768
  const parent = addedChildParentLogicalId(a.logicalId);
12731
12769
  if (!(parent !== void 0 && readParentLogical.has(parent))) continue;
12770
+ if (addedChildWasAdopted(a.logicalId, opts.physicalIdByLogical)) {
12771
+ adoptedStale.push(a.logicalId);
12772
+ continue;
12773
+ }
12732
12774
  kept.push({
12733
12775
  tier: "deleted",
12734
12776
  logicalId: a.logicalId,
@@ -12775,6 +12817,7 @@ function applyBaseline(findings, baseline, opts = {}) {
12775
12817
  if (removedFromTemplate.length > 0) opts.warn?.(formatRemovedFromTemplateNote(removedFromTemplate));
12776
12818
  if (replacedStale.length > 0) opts.warn?.(formatReplacedStaleNote(replacedStale));
12777
12819
  if (typeMismatchStale.length > 0) opts.warn?.(formatTypeMismatchStaleNote(typeMismatchStale));
12820
+ if (adoptedStale.length > 0) opts.warn?.(formatAdoptedStaleNote(adoptedStale));
12778
12821
  return kept;
12779
12822
  }
12780
12823
  /**
@@ -12815,6 +12858,17 @@ function formatTypeMismatchStaleNote(paths) {
12815
12858
  return `note: ${n === 1 ? `baseline entry (${paths[0]}) was` : `${n} baseline entries were`} recorded against a resource whose logicalId now has a DIFFERENT type — re-run \`cdkrd record\`.`;
12816
12859
  }
12817
12860
  /**
12861
+ * #1279: the folded one-line note for recorded out-of-band `added` resources that have since
12862
+ * been ADOPTED into the template (`cdk import`, or re-declared + deployed) — the child is no
12863
+ * longer enumerated as `added`, but its identifier matches a template resource's live physical
12864
+ * id, so it is alive and now IaC-managed, not deleted. Mirror of formatReplacedStaleNote. Pure
12865
+ * + exported for unit tests.
12866
+ */
12867
+ function formatAdoptedStaleNote(logicalIds) {
12868
+ const n = logicalIds.length;
12869
+ return `note: ${n === 1 ? `recorded added resource (${logicalIds[0]}) was` : `${n} recorded added resources were`} adopted into the template (now IaC-managed) — re-run \`cdkrd record\` to clean up the baseline.`;
12870
+ }
12871
+ /**
12818
12872
  * logicalId -> the resource's declared model, for applyBaseline's promotion check.
12819
12873
  * #1079: carries the WHOLE declared object (not just its top-level key set) so a NESTED
12820
12874
  * recorded path the user later declares is RESOLVED against the declared tree and folded