cdk-real-drift 0.9.2 → 0.9.4
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/README.md +4 -1
- package/dist/cli.js +133 -50
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -404,7 +404,10 @@ error (they select which comparison runs, so a combination is contradictory).
|
|
|
404
404
|
### Interactive prompts (TTY only, CI is never prompted)
|
|
405
405
|
|
|
406
406
|
Every option runs exactly the same code as the standalone commands. Prompts are
|
|
407
|
-
skipped under `--json`, `--show-all`, `--pre-deploy`,
|
|
407
|
+
skipped under `--json`, `--show-all`, `--pre-deploy`, `--fail`, and the scope
|
|
408
|
+
filters `--declared-only` / `--undeclared-only` (a filtered finding set must never
|
|
409
|
+
become a snapshot-complete baseline via the inline Record — use the standalone
|
|
410
|
+
`record` verb, which sees the unfiltered state, #779). A non-TTY run
|
|
408
411
|
never prompts: a required write decision without `--yes` errors with exit 2 (the
|
|
409
412
|
safe side). "Interactive" requires **both** a TTY stdin and a TTY stdout — so
|
|
410
413
|
**redirecting or piping the output** (`cdkrd check > report.txt`, `| tee`) is also
|
package/dist/cli.js
CHANGED
|
@@ -2208,7 +2208,10 @@ const KNOWN_DEFAULTS = {
|
|
|
2208
2208
|
Domain: "vpc"
|
|
2209
2209
|
},
|
|
2210
2210
|
"AWS::EC2::TransitGateway": { SecurityGroupReferencingSupport: "disable" },
|
|
2211
|
-
"AWS::EC2::FlowLog": {
|
|
2211
|
+
"AWS::EC2::FlowLog": {
|
|
2212
|
+
MaxAggregationInterval: 600,
|
|
2213
|
+
LogFormat: "${version} ${account-id} ${interface-id} ${srcaddr} ${dstaddr} ${srcport} ${dstport} ${protocol} ${packets} ${bytes} ${start} ${end} ${action} ${log-status}"
|
|
2214
|
+
},
|
|
2212
2215
|
"AWS::EC2::PlacementGroup": { SpreadLevel: "rack" },
|
|
2213
2216
|
"AWS::EC2::IPAM": { MeteredAccount: "ipam-owner" },
|
|
2214
2217
|
"AWS::EC2::ClientVpnEndpoint": {
|
|
@@ -2811,7 +2814,9 @@ const GENERATED_LOGICALID_PREFIX_PATHS = {
|
|
|
2811
2814
|
"AWS::Cognito::IdentityPool": new Set(["IdentityPoolName"]),
|
|
2812
2815
|
"AWS::Cognito::UserPool": new Set(["UserPoolName"]),
|
|
2813
2816
|
"AWS::Batch::JobDefinition": new Set(["JobDefinitionName"]),
|
|
2814
|
-
"AWS::EC2::LaunchTemplate": new Set(["LaunchTemplateName"])
|
|
2817
|
+
"AWS::EC2::LaunchTemplate": new Set(["LaunchTemplateName"]),
|
|
2818
|
+
"AWS::WAFv2::WebACL": new Set(["Name"]),
|
|
2819
|
+
"AWS::WAFv2::RegexPatternSet": new Set(["Name"])
|
|
2815
2820
|
};
|
|
2816
2821
|
const CFN_LOGICALID_RANDOM = /[-_][0-9A-Za-z]{12,}$/;
|
|
2817
2822
|
function isLogicalIdPrefixedGeneratedName(value, logicalId) {
|
|
@@ -2947,6 +2952,8 @@ function ebOptionSettingTier(namespace, optionName, value, envType) {
|
|
|
2947
2952
|
}
|
|
2948
2953
|
const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
|
|
2949
2954
|
"AWS::ElasticLoadBalancingV2::LoadBalancer": new Set(["SecurityGroups"]),
|
|
2955
|
+
"AWS::ApiGateway::ApiKey": new Set(["Value"]),
|
|
2956
|
+
"AWS::Backup::BackupVault": new Set(["EncryptionKeyArn"]),
|
|
2950
2957
|
"AWS::Batch::JobQueue": new Set(["JobQueueType"]),
|
|
2951
2958
|
"AWS::ECS::Service": new Set(["AvailabilityZoneRebalancing", "PlatformVersion"]),
|
|
2952
2959
|
"AWS::KinesisAnalyticsV2::Application": new Set(["ApplicationMaintenanceConfiguration"]),
|
|
@@ -3004,7 +3011,11 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
|
|
|
3004
3011
|
"ClusterVersion"
|
|
3005
3012
|
]),
|
|
3006
3013
|
"AWS::OpenSearchService::Domain": new Set(["OffPeakWindowOptions"]),
|
|
3007
|
-
"AWS::AmazonMQ::Broker": new Set([
|
|
3014
|
+
"AWS::AmazonMQ::Broker": new Set([
|
|
3015
|
+
"MaintenanceWindowStartTime",
|
|
3016
|
+
"SecurityGroups",
|
|
3017
|
+
"SubnetIds"
|
|
3018
|
+
]),
|
|
3008
3019
|
"AWS::EC2::Instance": new Set(["PrivateIpAddress"]),
|
|
3009
3020
|
"AWS::EC2::NetworkInterface": new Set([
|
|
3010
3021
|
"PrivateIpAddress",
|
|
@@ -4719,6 +4730,18 @@ function canonicalizeForCompare(v, resourceType) {
|
|
|
4719
4730
|
const base = canonicalizeIdArraysDeep(canonicalizeTagListsDeep(normalizePoliciesDeep(v), orderSig));
|
|
4720
4731
|
return resourceType === "AWS::WAFv2::WebACL" || resourceType === "AWS::WAFv2::RuleGroup" ? normalizeWafByteMatchDeep(base) : base;
|
|
4721
4732
|
}
|
|
4733
|
+
function sortObjectArraysDeep(v) {
|
|
4734
|
+
if (Array.isArray(v)) return sortUnorderedObjectArray(v.map(sortObjectArraysDeep));
|
|
4735
|
+
if (v && typeof v === "object") {
|
|
4736
|
+
const out = {};
|
|
4737
|
+
for (const [k, val] of Object.entries(v)) out[k] = sortObjectArraysDeep(val);
|
|
4738
|
+
return out;
|
|
4739
|
+
}
|
|
4740
|
+
return v;
|
|
4741
|
+
}
|
|
4742
|
+
function canonicalizeBaselineForCompare(v, resourceType) {
|
|
4743
|
+
return sortObjectArraysDeep(canonicalizeForCompare(stripAwsTagsDeep(stripCcApiAwsManagedFields(v)), resourceType));
|
|
4744
|
+
}
|
|
4722
4745
|
|
|
4723
4746
|
//#endregion
|
|
4724
4747
|
//#region src/diff/drift-calculator.ts
|
|
@@ -11159,17 +11182,8 @@ function carryForwardUnreadable(recorded, existing, findings) {
|
|
|
11159
11182
|
* type-agnostic over UNDECLARED snapshot fragments, which never carry an
|
|
11160
11183
|
* order-significant declared array, so an order-insensitive sort is safe here.
|
|
11161
11184
|
*/
|
|
11162
|
-
function baselineValueMatches(baselineValue, currentCanonicalValue) {
|
|
11163
|
-
return deepEqual(
|
|
11164
|
-
}
|
|
11165
|
-
function sortObjectArraysDeep(v) {
|
|
11166
|
-
if (Array.isArray(v)) return sortUnorderedObjectArray(v.map(sortObjectArraysDeep));
|
|
11167
|
-
if (v && typeof v === "object") {
|
|
11168
|
-
const out = {};
|
|
11169
|
-
for (const [k, val] of Object.entries(v)) out[k] = sortObjectArraysDeep(val);
|
|
11170
|
-
return out;
|
|
11171
|
-
}
|
|
11172
|
-
return v;
|
|
11185
|
+
function baselineValueMatches(baselineValue, currentCanonicalValue, resourceType) {
|
|
11186
|
+
return deepEqual(canonicalizeBaselineForCompare(baselineValue, resourceType), canonicalizeBaselineForCompare(currentCanonicalValue, resourceType));
|
|
11173
11187
|
}
|
|
11174
11188
|
const DELTA_IDENTITY_FIELDS = [
|
|
11175
11189
|
"Key",
|
|
@@ -11251,7 +11265,7 @@ function splitRecordedByBaseline(recorded, baseline) {
|
|
|
11251
11265
|
const changed = [];
|
|
11252
11266
|
for (const entry of recorded) {
|
|
11253
11267
|
const baselineEntry = baseline.recorded.find((a) => a.logicalId === entry.logicalId && a.path === entry.path && a.resourceType === entry.resourceType);
|
|
11254
|
-
if (baselineEntry && baselineValueMatches(baselineEntry.value, entry.value)) unchanged.push(entry);
|
|
11268
|
+
if (baselineEntry && baselineValueMatches(baselineEntry.value, entry.value, entry.resourceType)) unchanged.push(entry);
|
|
11255
11269
|
else changed.push(entry);
|
|
11256
11270
|
}
|
|
11257
11271
|
return {
|
|
@@ -11400,11 +11414,11 @@ function applyBaseline(findings, baseline, opts = {}) {
|
|
|
11400
11414
|
});
|
|
11401
11415
|
continue;
|
|
11402
11416
|
}
|
|
11403
|
-
if (entry && baselineValueMatches(entry.value, f.actual)) continue;
|
|
11417
|
+
if (entry && baselineValueMatches(entry.value, f.actual, f.resourceType)) continue;
|
|
11404
11418
|
if (entry) {
|
|
11405
11419
|
kept.push({
|
|
11406
11420
|
...f,
|
|
11407
|
-
desired: canonicalizeForCompare(entry.value),
|
|
11421
|
+
desired: canonicalizeForCompare(entry.value, f.resourceType),
|
|
11408
11422
|
note: f.note ? `${f.note}; changed since record` : "changed since record"
|
|
11409
11423
|
});
|
|
11410
11424
|
continue;
|
|
@@ -11420,13 +11434,13 @@ function applyBaseline(findings, baseline, opts = {}) {
|
|
|
11420
11434
|
continue;
|
|
11421
11435
|
}
|
|
11422
11436
|
const entry = replacedLogical.has(f.logicalId) ? void 0 : recorded.find((a) => entryMatches(a, f));
|
|
11423
|
-
if (entry && baselineValueMatches(entry.value, f.actual)) continue;
|
|
11437
|
+
if (entry && baselineValueMatches(entry.value, f.actual, f.resourceType)) continue;
|
|
11424
11438
|
if (entry) {
|
|
11425
|
-
const delta = identityArrayDelta(canonicalizeForCompare(entry.value), f.actual);
|
|
11439
|
+
const delta = identityArrayDelta(canonicalizeForCompare(entry.value, f.resourceType), f.actual);
|
|
11426
11440
|
kept.push({
|
|
11427
11441
|
...f,
|
|
11428
11442
|
tier: "undeclared",
|
|
11429
|
-
desired: canonicalizeForCompare(entry.value),
|
|
11443
|
+
desired: canonicalizeForCompare(entry.value, f.resourceType),
|
|
11430
11444
|
...delta && { arrayDelta: delta }
|
|
11431
11445
|
});
|
|
11432
11446
|
continue;
|
|
@@ -13596,6 +13610,9 @@ function isManagedPolicyAttachmentMember(f) {
|
|
|
13596
13610
|
function isNestedSdkWritable(f) {
|
|
13597
13611
|
return SDK_NESTED_WRITERS[f.resourceType]?.match(f.path) ?? false;
|
|
13598
13612
|
}
|
|
13613
|
+
function isContractOp(op) {
|
|
13614
|
+
return op.contract === true;
|
|
13615
|
+
}
|
|
13599
13616
|
function nullHuskRemovalOps(model) {
|
|
13600
13617
|
const ops = [];
|
|
13601
13618
|
const walk = (value, pointer) => {
|
|
@@ -13604,6 +13621,7 @@ function nullHuskRemovalOps(model) {
|
|
|
13604
13621
|
if (pointer !== "") ops.push({
|
|
13605
13622
|
op: "remove",
|
|
13606
13623
|
path: pointer,
|
|
13624
|
+
contract: true,
|
|
13607
13625
|
human: `strip null array husk at ${pointer}`
|
|
13608
13626
|
});
|
|
13609
13627
|
return;
|
|
@@ -14469,6 +14487,7 @@ function recordOutcomeMessage(stackName, path, count, refreshedOnly, hadPriorBas
|
|
|
14469
14487
|
function revertSelectOptions(plan) {
|
|
14470
14488
|
const options = [];
|
|
14471
14489
|
for (const item of plan.items) for (const op of item.ops) {
|
|
14490
|
+
if (isContractOp(op)) continue;
|
|
14472
14491
|
const marker = item.kind === "delete" ? " (DELETE)" : op.op === "remove" ? " (REMOVE)" : "";
|
|
14473
14492
|
options.push({
|
|
14474
14493
|
value: revertOpKey(item, op),
|
|
@@ -14482,13 +14501,31 @@ function revertOpKey(item, op) {
|
|
|
14482
14501
|
const attr = op.attributeKey !== void 0 ? `${op.attributeKey}` : "";
|
|
14483
14502
|
return `${item.logicalId}${item.kind}${op.path}${attr}`;
|
|
14484
14503
|
}
|
|
14485
|
-
/**
|
|
14504
|
+
/**
|
|
14505
|
+
* Keep only the selected ops; items left with no REAL op drop out. Pure + exported.
|
|
14506
|
+
*
|
|
14507
|
+
* #967: a CONTRACT op (null-husk strip) is never a selectable row, so it is never in
|
|
14508
|
+
* `picked` — but it is coupled to its item's real revert ops (without the strip, the CC
|
|
14509
|
+
* patch hard-fails model validation, #641). So it is NOT filtered by the pick set: it
|
|
14510
|
+
* ALWAYS rides along an item that retains ≥1 real (non-contract) selected op, and is
|
|
14511
|
+
* DROPPED with the whole item when the user selected none of that item's real ops.
|
|
14512
|
+
* This keeps both invariants: a real revert op can never be sent without its coupled
|
|
14513
|
+
* husk strip, and a husk strip can never be sent alone as a user-chosen write.
|
|
14514
|
+
*/
|
|
14486
14515
|
function filterRevertPlan(plan, picked) {
|
|
14487
14516
|
return {
|
|
14488
|
-
items: plan.items.map((item) =>
|
|
14489
|
-
|
|
14490
|
-
|
|
14491
|
-
|
|
14517
|
+
items: plan.items.map((item) => {
|
|
14518
|
+
const realSelected = item.ops.filter((op) => !isContractOp(op) && picked.has(revertOpKey(item, op)));
|
|
14519
|
+
if (realSelected.length === 0) return {
|
|
14520
|
+
...item,
|
|
14521
|
+
ops: []
|
|
14522
|
+
};
|
|
14523
|
+
const contract = item.ops.filter(isContractOp);
|
|
14524
|
+
return {
|
|
14525
|
+
...item,
|
|
14526
|
+
ops: [...contract, ...realSelected]
|
|
14527
|
+
};
|
|
14528
|
+
}).filter((item) => item.ops.length > 0),
|
|
14492
14529
|
notRevertable: plan.notRevertable
|
|
14493
14530
|
};
|
|
14494
14531
|
}
|
|
@@ -14496,6 +14533,16 @@ function revertSelectMessage(stackName, region) {
|
|
|
14496
14533
|
return `${stackLabel$1(stackName, region)}: select the op(s) to revert (unselected are not written)`;
|
|
14497
14534
|
}
|
|
14498
14535
|
/**
|
|
14536
|
+
* #967: the op count SHOWN to the user (confirm prompt + --dry-run preview) counts only
|
|
14537
|
+
* REAL revert ops — a CONTRACT op (null-husk strip) is plumbing coupled to a real op,
|
|
14538
|
+
* not a distinct write the user chose, so counting it would inflate the number the user
|
|
14539
|
+
* consents to. The full augmented patch (contract ops included) is still what is SENT to
|
|
14540
|
+
* AWS; this is purely the user-facing intent count. Pure + exported for unit tests.
|
|
14541
|
+
*/
|
|
14542
|
+
function realOpCount(plan) {
|
|
14543
|
+
return plan.items.reduce((n, i) => n + i.ops.filter((op) => !isContractOp(op)).length, 0);
|
|
14544
|
+
}
|
|
14545
|
+
/**
|
|
14499
14546
|
* Record the current undeclared state into the baseline file. In an interactive run
|
|
14500
14547
|
* (no --yes) the user picks WHICH undeclared values to record (selective record, R14).
|
|
14501
14548
|
* When an existing baseline is present the multiselect shows only the DELTA from it
|
|
@@ -14725,7 +14772,7 @@ function formatPlan(stackName, region, plan, opts = {}) {
|
|
|
14725
14772
|
const planByResource = /* @__PURE__ */ new Map();
|
|
14726
14773
|
for (const item of plan.items) {
|
|
14727
14774
|
const g = planByResource.get(item.logicalId);
|
|
14728
|
-
const humans = item.ops.map((op) => op.human);
|
|
14775
|
+
const humans = item.ops.filter((op) => !isContractOp(op)).map((op) => op.human);
|
|
14729
14776
|
if (g) g.humans.push(...humans);
|
|
14730
14777
|
else planByResource.set(item.logicalId, {
|
|
14731
14778
|
displayId: item.displayId,
|
|
@@ -14795,6 +14842,36 @@ const CONVERGE_RETRY_DELAY_MS = 3e3;
|
|
|
14795
14842
|
function includeUnrecordedRemovals(removeUnrecorded, interactive, yes) {
|
|
14796
14843
|
return removeUnrecorded || interactive && !yes;
|
|
14797
14844
|
}
|
|
14845
|
+
function augmentCcItemOps(item, schemas, liveByLogical, declaredByLogical) {
|
|
14846
|
+
if (item.kind !== "cc") return item;
|
|
14847
|
+
const liveRaw = liveByLogical.get(item.logicalId);
|
|
14848
|
+
const tagged = tagPreservingOps(item.ops, liveRaw);
|
|
14849
|
+
const extra = writeOnlyReincludeOps(declaredByLogical(item.logicalId), schemas.get(item.resourceType), tagged);
|
|
14850
|
+
const strip = rejectedEmptyStripOps(item.resourceType, [...tagged, ...extra], liveRaw);
|
|
14851
|
+
const combined = [
|
|
14852
|
+
...tagged,
|
|
14853
|
+
...extra,
|
|
14854
|
+
...strip
|
|
14855
|
+
];
|
|
14856
|
+
const ops = combined.length > tagged.length ? combined : tagged;
|
|
14857
|
+
return {
|
|
14858
|
+
...item,
|
|
14859
|
+
ops
|
|
14860
|
+
};
|
|
14861
|
+
}
|
|
14862
|
+
function attributeOpFailure(item, error) {
|
|
14863
|
+
if (item.kind === "delete") return error;
|
|
14864
|
+
const paths = [...new Set(item.ops.map((o) => o.path).filter((p) => p.length > 0))];
|
|
14865
|
+
if (paths.length === 0) return error;
|
|
14866
|
+
const prefix = `[${paths.join(", ")}]`;
|
|
14867
|
+
return error.startsWith(prefix) ? error : `${prefix}: ${error}`;
|
|
14868
|
+
}
|
|
14869
|
+
function augmentRevertPlan(plan, schemas, liveByLogical, declaredByLogical) {
|
|
14870
|
+
return {
|
|
14871
|
+
...plan,
|
|
14872
|
+
items: plan.items.map((item) => augmentCcItemOps(item, schemas, liveByLogical, declaredByLogical))
|
|
14873
|
+
};
|
|
14874
|
+
}
|
|
14798
14875
|
async function revertStack(p) {
|
|
14799
14876
|
const { stackName, region, gathered, baseline, config, dryRun, yes, removeUnrecorded, verbose, interactive, autoSelectAll, waitMs, waitNow, waitSleep } = p;
|
|
14800
14877
|
const out = p.json ? () => {} : console.log;
|
|
@@ -14814,6 +14891,9 @@ async function revertStack(p) {
|
|
|
14814
14891
|
accountId: gathered.desired.accountId,
|
|
14815
14892
|
region
|
|
14816
14893
|
}, config);
|
|
14894
|
+
const resByLogical = new Map(gathered.desired.resources.map((res) => [res.logicalId, res]));
|
|
14895
|
+
const declaredForLogical = (logicalId) => resByLogical.get(logicalId)?.declared;
|
|
14896
|
+
const augment = (pl) => augmentRevertPlan(pl, gathered.schemas, gathered.liveByLogical, declaredForLogical);
|
|
14817
14897
|
let plan = buildRevertPlan(drifted, baseline, {
|
|
14818
14898
|
removeUnrecorded: includeRemovals,
|
|
14819
14899
|
schemas: gathered.schemas,
|
|
@@ -14828,7 +14908,7 @@ async function revertStack(p) {
|
|
|
14828
14908
|
aborted: false
|
|
14829
14909
|
};
|
|
14830
14910
|
}
|
|
14831
|
-
if (!p.json) printPlan(stackName, region, plan, {
|
|
14911
|
+
if (!p.json) printPlan(stackName, region, augment(plan), {
|
|
14832
14912
|
verbose,
|
|
14833
14913
|
unrecordedGuidance: !includeRemovals && drifted.some((f) => f.unrecorded === true)
|
|
14834
14914
|
});
|
|
@@ -14844,13 +14924,14 @@ async function revertStack(p) {
|
|
|
14844
14924
|
};
|
|
14845
14925
|
}
|
|
14846
14926
|
if (dryRun) {
|
|
14847
|
-
const
|
|
14848
|
-
|
|
14927
|
+
const augmented = augment(plan);
|
|
14928
|
+
const opCount = realOpCount(augmented);
|
|
14929
|
+
out(`\n(dry-run) would apply ${opCount} op(s) to ${augmented.items.length} resource(s). No changes made.`);
|
|
14849
14930
|
return {
|
|
14850
14931
|
exit: 0,
|
|
14851
14932
|
aborted: false,
|
|
14852
14933
|
plannedOps: opCount,
|
|
14853
|
-
plannedResources:
|
|
14934
|
+
plannedResources: augmented.items.length
|
|
14854
14935
|
};
|
|
14855
14936
|
}
|
|
14856
14937
|
if (!yes) {
|
|
@@ -14881,8 +14962,9 @@ async function revertStack(p) {
|
|
|
14881
14962
|
};
|
|
14882
14963
|
}
|
|
14883
14964
|
}
|
|
14884
|
-
const
|
|
14885
|
-
const
|
|
14965
|
+
const confirmPlan = augment(plan);
|
|
14966
|
+
const opCount = realOpCount(confirmPlan);
|
|
14967
|
+
const deleteCount = confirmPlan.items.filter((i) => i.kind === "delete").length;
|
|
14886
14968
|
const ok = await confirm({
|
|
14887
14969
|
message: revertConfirmMessage(stackName, region, opCount, plan.notRevertable.length, deleteCount),
|
|
14888
14970
|
initialValue: false
|
|
@@ -14895,6 +14977,7 @@ async function revertStack(p) {
|
|
|
14895
14977
|
};
|
|
14896
14978
|
}
|
|
14897
14979
|
}
|
|
14980
|
+
plan = augment(plan);
|
|
14898
14981
|
const inProgress = await stackInProgressRefusal(stackName, region);
|
|
14899
14982
|
if (inProgress) {
|
|
14900
14983
|
console.error("\n" + inProgress);
|
|
@@ -14908,7 +14991,6 @@ async function revertStack(p) {
|
|
|
14908
14991
|
region,
|
|
14909
14992
|
...CLIENT_TIMEOUTS
|
|
14910
14993
|
});
|
|
14911
|
-
const byLogical = new Map(gathered.desired.resources.map((res) => [res.logicalId, res]));
|
|
14912
14994
|
const failedDeleteIds = /* @__PURE__ */ new Set();
|
|
14913
14995
|
const failedUpdateIds = /* @__PURE__ */ new Set();
|
|
14914
14996
|
const applied = [];
|
|
@@ -14928,7 +15010,7 @@ async function revertStack(p) {
|
|
|
14928
15010
|
if (item.kind === "delete") continue;
|
|
14929
15011
|
let r;
|
|
14930
15012
|
if (item.kind === "sdk") {
|
|
14931
|
-
const res =
|
|
15013
|
+
const res = resByLogical.get(item.logicalId);
|
|
14932
15014
|
r = await retryTransient(async () => {
|
|
14933
15015
|
try {
|
|
14934
15016
|
const writer = resolveSdkWriter(item.resourceType, item.ops);
|
|
@@ -14951,26 +15033,14 @@ async function revertStack(p) {
|
|
|
14951
15033
|
}
|
|
14952
15034
|
}, buildRetryOpts(item.displayId));
|
|
14953
15035
|
} else {
|
|
14954
|
-
const res =
|
|
14955
|
-
|
|
14956
|
-
const tagged = tagPreservingOps(item.ops, gathered.liveByLogical.get(item.logicalId));
|
|
14957
|
-
const extra = writeOnlyReincludeOps(res?.declared, gathered.schemas.get(item.resourceType), tagged);
|
|
14958
|
-
const strip = rejectedEmptyStripOps(item.resourceType, [...tagged, ...extra], gathered.liveByLogical.get(item.logicalId));
|
|
14959
|
-
const combined = [
|
|
14960
|
-
...tagged,
|
|
14961
|
-
...extra,
|
|
14962
|
-
...strip
|
|
14963
|
-
];
|
|
14964
|
-
r = await applyRevertItem(cc, {
|
|
14965
|
-
...item,
|
|
14966
|
-
ops: combined.length > tagged.length ? combined : tagged
|
|
14967
|
-
}, identifier, buildRetryOpts(item.displayId));
|
|
15036
|
+
const res = resByLogical.get(item.logicalId);
|
|
15037
|
+
r = await applyRevertItem(cc, item, CC_IDENTIFIER_ADAPTERS[item.resourceType]?.(item.physicalId, res?.declared ?? {}, region, gathered.desired.accountId) ?? item.physicalId, buildRetryOpts(item.displayId));
|
|
14968
15038
|
}
|
|
14969
15039
|
applied.push({
|
|
14970
15040
|
logicalId: item.logicalId,
|
|
14971
15041
|
displayId: item.displayId,
|
|
14972
15042
|
ok: r.ok,
|
|
14973
|
-
...r.error !== void 0 && { error: r.error },
|
|
15043
|
+
...r.error !== void 0 && { error: attributeOpFailure(item, r.error) },
|
|
14974
15044
|
...r.hint !== void 0 && { hint: r.hint }
|
|
14975
15045
|
});
|
|
14976
15046
|
if (!r.ok) worst = Math.max(worst, 2);
|
|
@@ -16229,6 +16299,19 @@ function finalCheckExit(code, fail) {
|
|
|
16229
16299
|
* who can make the decision. It is gated OUT of every machine/automation mode:
|
|
16230
16300
|
* - --json / --show-all / --pre-deploy — machine output or baseline-untouched contracts,
|
|
16231
16301
|
* - --fail — the CI drift-exit path,
|
|
16302
|
+
* - #779: --declared-only / --undeclared-only — a SCOPE filter is active, so `findings`
|
|
16303
|
+
* has been reduced to one tier (declared-only drops the whole undeclared/added/atDefault
|
|
16304
|
+
* tier; undeclared-only drops declared plus its readGap/unresolved byproducts). The
|
|
16305
|
+
* interactive menu's Record path feeds THAT filtered set into writeBaseline, and
|
|
16306
|
+
* computeCompleteResources — which only blocks snapshot-completeness on the tiers that
|
|
16307
|
+
* were just filtered out (skipped/deleted/readGap/unrecorded-undeclared) — then stamps
|
|
16308
|
+
* every readable resource snapshot-complete with an INCOMPLETE `recorded` list. A later
|
|
16309
|
+
* plain `check` reads the genuinely-undeclared values on those "complete" resources as
|
|
16310
|
+
* "appeared since record" -> a false confirmed-drift storm (exit 1 under --fail). Under
|
|
16311
|
+
* --declared-only the HELP/in-run note also PROMISES the baseline is untouched, which the
|
|
16312
|
+
* Record offer would violate. A filtered finding set must never become a snapshot-complete
|
|
16313
|
+
* baseline, so no interactive Record/Revert is offered under either scope flag; the
|
|
16314
|
+
* standalone `record` verb (unfiltered) remains the way to establish one.
|
|
16232
16315
|
* - #1054: --yes — `--yes` has NO documented `check` contract (HELP scopes it to record /
|
|
16233
16316
|
* ignore / revert; check's automation flag is --fail / non-TTY). In the menu the USER is
|
|
16234
16317
|
* the decision-maker, but `--yes` means "no decision needed" in the record/ignore/revert
|
|
@@ -16238,7 +16321,7 @@ function finalCheckExit(code, fail) {
|
|
|
16238
16321
|
* Pure + exported for tests.
|
|
16239
16322
|
*/
|
|
16240
16323
|
function shouldOfferInteractiveResolve(a, ctx) {
|
|
16241
|
-
return (ctx.code === 1 || ctx.hasUnrecorded || !ctx.hasBaseline) && !a.json && !a.showAll && !a.preDeploy && !a.fail && !a.yes && ctx.interactive;
|
|
16324
|
+
return (ctx.code === 1 || ctx.hasUnrecorded || !ctx.hasBaseline) && !a.json && !a.showAll && !a.preDeploy && !a.fail && !a.yes && !a.declaredOnly && !a.undeclaredOnly && ctx.interactive;
|
|
16242
16325
|
}
|
|
16243
16326
|
/**
|
|
16244
16327
|
* #781: does a committed baseline exist for this stack IN THE REGION being checked?
|