cdk-real-drift 0.4.35 → 0.4.37
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 +55 -12
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2685,6 +2685,9 @@ const CONTEXT_ARN_DEFAULTS = {
|
|
|
2685
2685
|
"AWS::ResourceExplorer2::View": { Scope: "arn:{partition}:iam::{accountId}:root" },
|
|
2686
2686
|
"AWS::KinesisVideo::Stream": { KmsKeyId: "arn:{partition}:kms:{region}:{accountId}:alias/aws/kinesisvideo" },
|
|
2687
2687
|
"AWS::AutoScaling::AutoScalingGroup": { ServiceLinkedRoleARN: "arn:{partition}:iam::{accountId}:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling" },
|
|
2688
|
+
"AWS::Batch::ComputeEnvironment": { ServiceRole: "arn:{partition}:iam::{accountId}:role/aws-service-role/batch.amazonaws.com/AWSServiceRoleForBatch" },
|
|
2689
|
+
"AWS::CodeBuild::Project": { EncryptionKey: "arn:{partition}:kms:{region}:{accountId}:alias/aws/s3" },
|
|
2690
|
+
"AWS::SSM::MaintenanceWindowTask": { ServiceRoleArn: "arn:{partition}:iam::{accountId}:role/aws-service-role/ssm.amazonaws.com/AWSServiceRoleForAmazonSSM" },
|
|
2688
2691
|
"AWS::LakeFormation::Tag": { CatalogId: "{accountId}" },
|
|
2689
2692
|
"AWS::S3::AccessPoint": { BucketAccountId: "{accountId}" },
|
|
2690
2693
|
"AWS::EC2::VPCPeeringConnection": { PeerOwnerId: "{accountId}" },
|
|
@@ -10579,7 +10582,31 @@ function splitRecordedByBaseline(recorded, baseline) {
|
|
|
10579
10582
|
function selectRecorded(findings, selectedKeys) {
|
|
10580
10583
|
return buildRecorded(findings).filter((e) => selectedKeys.has(recordedKey(e)));
|
|
10581
10584
|
}
|
|
10582
|
-
|
|
10585
|
+
function pathSegments$1(path) {
|
|
10586
|
+
return path.replace(/\[([^\]]*)\]/g, ".$1").split(".").filter((s) => s.length > 0);
|
|
10587
|
+
}
|
|
10588
|
+
function descendDeclared(node, seg) {
|
|
10589
|
+
if (node === null || typeof node !== "object") return void 0;
|
|
10590
|
+
if (Array.isArray(node)) {
|
|
10591
|
+
for (const el of node) if (el !== null && typeof el === "object" && !Array.isArray(el)) {
|
|
10592
|
+
for (const idf of DELTA_IDENTITY_FIELDS) if (String(el[idf]) === seg) return el;
|
|
10593
|
+
}
|
|
10594
|
+
const idx = Number(seg);
|
|
10595
|
+
return Number.isInteger(idx) && idx >= 0 && idx < node.length ? node[idx] : void 0;
|
|
10596
|
+
}
|
|
10597
|
+
return node[seg];
|
|
10598
|
+
}
|
|
10599
|
+
function declaredPathIsPromoted(declared, path) {
|
|
10600
|
+
if (declared === void 0) return false;
|
|
10601
|
+
let node = declared;
|
|
10602
|
+
for (const seg of pathSegments$1(path)) {
|
|
10603
|
+
if (node === null || typeof node !== "object") return true;
|
|
10604
|
+
const next = descendDeclared(node, seg);
|
|
10605
|
+
if (next === void 0) return false;
|
|
10606
|
+
node = next;
|
|
10607
|
+
}
|
|
10608
|
+
return true;
|
|
10609
|
+
}
|
|
10583
10610
|
/**
|
|
10584
10611
|
* Reconcile undeclared findings against the recorded baseline (per ENTRY, R62):
|
|
10585
10612
|
* - an undeclared finding matching an recorded entry (same value) is suppressed;
|
|
@@ -10705,7 +10732,7 @@ function applyBaseline(findings, baseline, opts = {}) {
|
|
|
10705
10732
|
removedFromTemplate.push(`${a.logicalId}.${a.path}`);
|
|
10706
10733
|
continue;
|
|
10707
10734
|
}
|
|
10708
|
-
if (
|
|
10735
|
+
if (declaredPathIsPromoted(opts.declaredByLogical?.get(a.logicalId), a.path)) {
|
|
10709
10736
|
promotedStale.push(`${a.logicalId}.${a.path}`);
|
|
10710
10737
|
continue;
|
|
10711
10738
|
}
|
|
@@ -10764,9 +10791,16 @@ function formatTypeMismatchStaleNote(paths) {
|
|
|
10764
10791
|
const n = paths.length;
|
|
10765
10792
|
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\`.`;
|
|
10766
10793
|
}
|
|
10767
|
-
/**
|
|
10794
|
+
/**
|
|
10795
|
+
* logicalId -> the resource's declared model, for applyBaseline's promotion check.
|
|
10796
|
+
* #1079: carries the WHOLE declared object (not just its top-level key set) so a NESTED
|
|
10797
|
+
* recorded path the user later declares is RESOLVED against the declared tree and folded
|
|
10798
|
+
* as promoted-to-code, rather than surfacing a false "removed since record". The map
|
|
10799
|
+
* feeds ApplyBaselineOptions.declaredByLogical; `applyBaseline` walks it per recorded path
|
|
10800
|
+
* via `declaredPathIsPromoted`.
|
|
10801
|
+
*/
|
|
10768
10802
|
function declaredKeysByLogical(resources) {
|
|
10769
|
-
return new Map(resources.map((r) => [r.logicalId,
|
|
10803
|
+
return new Map(resources.map((r) => [r.logicalId, r.declared]));
|
|
10770
10804
|
}
|
|
10771
10805
|
function constructPathsByLogical(resources) {
|
|
10772
10806
|
const m = /* @__PURE__ */ new Map();
|
|
@@ -13795,26 +13829,32 @@ async function revertStack(p) {
|
|
|
13795
13829
|
if (plan.items.length === 0) {
|
|
13796
13830
|
const dc = driftCount(drifted);
|
|
13797
13831
|
const uc = unrecordedCount(drifted);
|
|
13798
|
-
const
|
|
13799
|
-
out("\n" + style.drift(
|
|
13832
|
+
const reason = `nothing revertable — ${[...dc > 0 ? [`${dc} drift(s)`] : [], ...uc > 0 ? [`${uc} unrecorded value(s)`] : []].join(" + ")} remain.`;
|
|
13833
|
+
out("\n" + style.drift(reason));
|
|
13800
13834
|
return {
|
|
13801
13835
|
exit: 1,
|
|
13802
|
-
aborted: false
|
|
13836
|
+
aborted: false,
|
|
13837
|
+
refusedReason: reason
|
|
13803
13838
|
};
|
|
13804
13839
|
}
|
|
13805
13840
|
if (dryRun) {
|
|
13806
|
-
|
|
13841
|
+
const opCount = plan.items.reduce((n, i) => n + i.ops.length, 0);
|
|
13842
|
+
out(`\n(dry-run) would apply ${opCount} op(s) to ${plan.items.length} resource(s). No changes made.`);
|
|
13807
13843
|
return {
|
|
13808
13844
|
exit: 0,
|
|
13809
|
-
aborted: false
|
|
13845
|
+
aborted: false,
|
|
13846
|
+
plannedOps: opCount,
|
|
13847
|
+
plannedResources: plan.items.length
|
|
13810
13848
|
};
|
|
13811
13849
|
}
|
|
13812
13850
|
if (!yes) {
|
|
13813
13851
|
if (!interactive) {
|
|
13814
|
-
|
|
13852
|
+
const reason = "refusing to write to AWS non-interactively — pass --yes to apply (or --dry-run to preview).";
|
|
13853
|
+
console.error("\nrefusing to write to AWS non-interactively — pass --yes to apply (or --dry-run to preview).");
|
|
13815
13854
|
return {
|
|
13816
13855
|
exit: 2,
|
|
13817
|
-
aborted: false
|
|
13856
|
+
aborted: false,
|
|
13857
|
+
refusedReason: reason
|
|
13818
13858
|
};
|
|
13819
13859
|
}
|
|
13820
13860
|
if (!autoSelectAll) {
|
|
@@ -15514,7 +15554,10 @@ async function runRevert(args) {
|
|
|
15514
15554
|
reverted: outcome.reverted ?? 0,
|
|
15515
15555
|
failed: outcome.failed ?? 0,
|
|
15516
15556
|
aborted: outcome.aborted,
|
|
15517
|
-
exit: outcome.exit
|
|
15557
|
+
exit: outcome.exit,
|
|
15558
|
+
...outcome.plannedOps !== void 0 && { plannedOps: outcome.plannedOps },
|
|
15559
|
+
...outcome.plannedResources !== void 0 && { plannedResources: outcome.plannedResources },
|
|
15560
|
+
...outcome.refusedReason !== void 0 && { refusedReason: outcome.refusedReason }
|
|
15518
15561
|
});
|
|
15519
15562
|
} catch (e) {
|
|
15520
15563
|
if (isStackNotDeployed(e)) {
|