cdk-real-drift 0.2.77 → 0.2.78
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 +22 -7
- package/dist/cli.js +26 -6
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -345,7 +345,7 @@ CI (with `--yes`).
|
|
|
345
345
|
|
|
346
346
|
| option | meaning |
|
|
347
347
|
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
348
|
-
| `--region <r>` |
|
|
348
|
+
| `--region <r>` | a stack's own `env.region` ALWAYS wins; for an env-AGNOSTIC stack (no `env`) it falls back to `--region` (or `$AWS_REGION` / `$AWS_DEFAULT_REGION`), else the `--profile`'s region |
|
|
349
349
|
| `--profile <p>` | AWS profile (or `$AWS_PROFILE`) |
|
|
350
350
|
| `-a, --app <cmd\|cdk.out>` | CDK app command or pre-synthesized assembly dir (or `$CDKRD_APP` / cdk.json `"app"`); stack auto-discovery + construct paths |
|
|
351
351
|
| `-c, --context key=value` | context for synth (repeatable; cdk.json is the base layer) |
|
|
@@ -353,14 +353,14 @@ CI (with `--yes`).
|
|
|
353
353
|
| `--json` | machine-readable output (see [JSON contract](#json-output-contract)) |
|
|
354
354
|
| `--fail` | (check) exit 1 on drift and never prompt; for scripts/CI. Without it, check reports drift but exits 0 |
|
|
355
355
|
| `--strict` | (check) exit 1 when coverage is incomplete. A coverage gap is always surfaced loudly; `--strict` makes it CI-failing. Orthogonal to `--fail` |
|
|
356
|
-
| `--show-all` | inventory mode: show all current undeclared state, ignoring the baseline
|
|
357
|
-
| `--verbose` / `-v` | (check) expand the `info:` footer tiers / (revert) expand the
|
|
356
|
+
| `--show-all` | (check) inventory mode: show all current undeclared state, ignoring the baseline |
|
|
357
|
+
| `--verbose` / `-v` | (check) expand the `info:` footer tiers / (revert) expand the not-revertable summary to full lists; (record) itemizes nested sub-keys in the multiselect |
|
|
358
358
|
| `--pre-deploy` | (check) compare live vs the LOCAL synth template: the declared drift your next `cdk deploy` would silently overwrite |
|
|
359
359
|
| `--undeclared-only` | (check) undeclared drift only: pair cdkrd with `cdk drift` for the declared side |
|
|
360
360
|
| `--declared-only` | (check) declared drift vs the deployed template only (undeclared tier skipped; baseline untouched). Not `--pre-deploy` |
|
|
361
361
|
| `--dry-run` | (revert) print the plan; make no changes |
|
|
362
362
|
| `--wait[=DURATION]` | (revert) on a transient "resource is mid-update" error (e.g. Route53Resolver `RSLVR-00705`) keep retrying until it settles, up to DURATION (default `10m`; e.g. `--wait=5m`, `--wait=90s`) |
|
|
363
|
-
| `--remove-unrecorded` | (revert) REMOVE unrecorded values + DELETE unrecorded added resources in a no-prompt run (`--yes`/CI); an interactive revert already lists them
|
|
363
|
+
| `--remove-unrecorded` | (revert, and check for its inline revert) REMOVE unrecorded values + DELETE unrecorded added resources in a no-prompt run (`--yes`/CI); an interactive revert already lists them |
|
|
364
364
|
| `--yes` / `-y` | skip confirmations (revert apply; record records all without the multiselect) |
|
|
365
365
|
|
|
366
366
|
Unknown options (`--apq`) and options missing their value (`--app` at the end of
|
|
@@ -371,8 +371,10 @@ the line) are errors (exit `2`): a typo'd flag never silently becomes a stack na
|
|
|
371
371
|
Every option runs exactly the same code as the standalone commands. Prompts are
|
|
372
372
|
skipped under `--json`, `--show-all`, `--pre-deploy`, and `--fail`. A non-TTY run
|
|
373
373
|
never prompts: a required write decision without `--yes` errors with exit 2 (the
|
|
374
|
-
safe side); `--yes`
|
|
375
|
-
|
|
374
|
+
safe side); `--yes` in a TTY skips the write confirmation AND each verb's selection
|
|
375
|
+
multiselect — `record` records ALL, `ignore` ignores ALL, `revert` applies the full
|
|
376
|
+
plan. Only `check`'s action menu (Record / Revert / Ignore / …) still shows under
|
|
377
|
+
`--yes`.
|
|
376
378
|
|
|
377
379
|
- **`check` with drift** offers `Record / Revert / Ignore / Decide per finding /
|
|
378
380
|
Nothing` (see [The model](#the-model-one-verb-you-run-three-it-offers)). Each
|
|
@@ -577,7 +579,9 @@ valid JSON value nor JSONL; multi-stack `--json` was unparseable — issue #755.
|
|
|
577
579
|
A **stack that errored or was skipped** before it could be checked still appears as an
|
|
578
580
|
element so a consumer sees which stacks ran: it carries `"error": "<reason>"` alongside
|
|
579
581
|
`"drifted": 0` and an empty `"findings": []`. (`error` is absent on a
|
|
580
|
-
successfully-checked stack.)
|
|
582
|
+
successfully-checked stack.) Its `stack` is `"<name> (<region>)"` as usual, EXCEPT
|
|
583
|
+
when the failure is that no region could be resolved for the stack — then `stack`
|
|
584
|
+
is the bare `"<name>"` (no ` (<region>)` suffix), since there is no region to name.
|
|
581
585
|
|
|
582
586
|
A **stack deleted out of band** — its committed baseline proves it was once deployed but
|
|
583
587
|
it is now gone from CloudFormation — is the strongest drift, so it carries
|
|
@@ -625,6 +629,17 @@ Optional per-finding fields, present only when they apply:
|
|
|
625
629
|
- `modelReadFailed` (`true`) — an `added` resource whose full live model could not be
|
|
626
630
|
read this run (`actual` is only the enumerator's identity snippet); it exists but is
|
|
627
631
|
not change-watchable until the next check.
|
|
632
|
+
- `wholeArrayRevert` (`{ path, value }`) — **internal, revert-only** metadata on a
|
|
633
|
+
`declared` per-element finding inside an unordered object-array (a set the
|
|
634
|
+
service reorders — SecurityGroup rules, PrefixList entries, …): it carries the
|
|
635
|
+
WHOLE declared array so `revert` replaces the array as a unit instead of
|
|
636
|
+
index-patching a sorted position that does not map to the live index.
|
|
637
|
+
Display-only for the report; a consumer can ignore it.
|
|
638
|
+
- `siblingPolicyNames` (`"unresolved"`) — **internal, revert-only** sentinel on a
|
|
639
|
+
`declared` IAM Role `Policies` finding whose sibling `AWS::IAM::Policy` names
|
|
640
|
+
could not be resolved; `revert` reads it and refuses to act (a per-entry revert
|
|
641
|
+
could delete a managed inline policy). The only emitted value is the
|
|
642
|
+
`"unresolved"` string; a consumer can ignore it.
|
|
628
643
|
- On an `added` finding, `desired` carries the **recorded baseline model** and `actual`
|
|
629
644
|
the live one (so a recorded `added` resource that changed shows the delta), and
|
|
630
645
|
`unrecorded` marks a never-recorded one as potential drift.
|
package/dist/cli.js
CHANGED
|
@@ -2981,7 +2981,10 @@ function isPropertiesFileEqual(a, b) {
|
|
|
2981
2981
|
for (const [k, v] of ma) if (mb.get(k) !== v) return false;
|
|
2982
2982
|
return true;
|
|
2983
2983
|
}
|
|
2984
|
-
const CASE_INSENSITIVE_ARRAY_PATHS = {
|
|
2984
|
+
const CASE_INSENSITIVE_ARRAY_PATHS = {
|
|
2985
|
+
"AWS::ApiGatewayV2::Api": new Set(["CorsConfiguration.AllowHeaders", "CorsConfiguration.ExposeHeaders"]),
|
|
2986
|
+
"AWS::Lambda::Url": new Set(["Cors.AllowHeaders", "Cors.ExposeHeaders"])
|
|
2987
|
+
};
|
|
2985
2988
|
function isCaseInsensitiveEqualScalarSet(a, b) {
|
|
2986
2989
|
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
|
|
2987
2990
|
if (!a.every((v) => typeof v === "string") || !b.every((v) => typeof v === "string")) return false;
|
|
@@ -4151,7 +4154,8 @@ const MEANINGFUL_WHEN_OFF = {
|
|
|
4151
4154
|
"AWS::EC2::Instance": { SourceDestCheck: () => true },
|
|
4152
4155
|
"AWS::EC2::NetworkInterface": { SourceDestCheck: () => true },
|
|
4153
4156
|
"AWS::Cognito::UserPoolClient": { EnableTokenRevocation: () => true },
|
|
4154
|
-
"AWS::CloudWatch::CompositeAlarm": { ActionsEnabled: () => true }
|
|
4157
|
+
"AWS::CloudWatch::CompositeAlarm": { ActionsEnabled: () => true },
|
|
4158
|
+
"AWS::ApplicationInsights::Application": { CWEMonitorEnabled: () => true }
|
|
4155
4159
|
};
|
|
4156
4160
|
const stripCognitoAttrPrefix = (id) => id.replace(/^(custom|dev):/, "");
|
|
4157
4161
|
const IDENTITY_KEYED_SUBSET_ARRAYS = {
|
|
@@ -4964,7 +4968,10 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
4964
4968
|
if (LATEST_SENTINEL_PATHS[resourceType]?.has(d.path) && isLatestSentinelMatch(d.stateValue, d.awsValue)) continue;
|
|
4965
4969
|
if (INTELLIGENT_TIERING_PATHS[resourceType]?.has(d.path) && isIntelligentTieringMatch(d.stateValue, d.awsValue)) continue;
|
|
4966
4970
|
if ((UNORDERED_ARRAY_PROPS[resourceType]?.has(d.path) || UNORDERED_ARRAY_PROPS[resourceType]?.has(d.path.replace(/\.\d+(?=\.|$)/g, ".*")) || schema.unorderedScalarPaths?.includes(d.path)) && isEqualUnorderedScalarSet(d.stateValue, d.awsValue)) continue;
|
|
4967
|
-
if (isTrivialEmpty(d.stateValue) && d.path in knownDef && deepEqual(d.awsValue, knownDef[d.path])
|
|
4971
|
+
if (isTrivialEmpty(d.stateValue) && d.path in knownDef && deepEqual(d.awsValue, knownDef[d.path]) && !(MEANINGFUL_WHEN_OFF[resourceType]?.[d.path]?.({
|
|
4972
|
+
declared,
|
|
4973
|
+
live
|
|
4974
|
+
}) ?? false)) continue;
|
|
4968
4975
|
const unorderedExtra = unorderedObjArray && Array.isArray(declaredVal) && declaredRemapSource ? {
|
|
4969
4976
|
path: remapSortedIndexToDeclared(d.path, k, declaredVal, declaredRemapSource),
|
|
4970
4977
|
wholeArrayRevert: {
|
|
@@ -8845,6 +8852,7 @@ function parseSchema(schemaJson) {
|
|
|
8845
8852
|
const defaultPaths = collectDefaultPaths(schema.definitions ?? {}, schema.properties ?? {});
|
|
8846
8853
|
const unorderedArrayPaths = collectUnorderedArrayPaths(schema.definitions ?? {}, schema.properties ?? {});
|
|
8847
8854
|
const freeFormMapPaths = collectFreeFormMapPaths(schema.definitions ?? {}, schema.properties ?? {});
|
|
8855
|
+
const updatable = schema.handlers === void 0 ? void 0 : Object.hasOwn(schema.handlers, "update");
|
|
8848
8856
|
return {
|
|
8849
8857
|
readOnly: topLevel(readOnlyPaths),
|
|
8850
8858
|
writeOnly: topLevel(writeOnlyPaths),
|
|
@@ -8856,7 +8864,8 @@ function parseSchema(schemaJson) {
|
|
|
8856
8864
|
defaultPaths,
|
|
8857
8865
|
unorderedScalarPaths: unorderedArrayPaths.scalar,
|
|
8858
8866
|
unorderedObjectArrayPaths: unorderedArrayPaths.object,
|
|
8859
|
-
freeFormMapPaths
|
|
8867
|
+
freeFormMapPaths,
|
|
8868
|
+
updatable
|
|
8860
8869
|
};
|
|
8861
8870
|
}
|
|
8862
8871
|
|
|
@@ -11916,6 +11925,15 @@ function buildRevertPlan(findings, baseline, opts = {}) {
|
|
|
11916
11925
|
});
|
|
11917
11926
|
continue;
|
|
11918
11927
|
}
|
|
11928
|
+
if (schema?.updatable === false && !SDK_WRITERS[f.resourceType] && !propScoped && !nestedScoped) {
|
|
11929
|
+
notRevertable.push({
|
|
11930
|
+
displayId,
|
|
11931
|
+
resourceType: f.resourceType,
|
|
11932
|
+
path: f.path,
|
|
11933
|
+
reason: "type has no update handler — detect/record only"
|
|
11934
|
+
});
|
|
11935
|
+
continue;
|
|
11936
|
+
}
|
|
11919
11937
|
const kind = SDK_WRITERS[f.resourceType] || propScoped || nestedScoped ? "sdk" : "cc";
|
|
11920
11938
|
let toRevert = f;
|
|
11921
11939
|
const sgSide = f.tier === "declared" && f.resourceType === "AWS::EC2::SecurityGroup" ? SG_REVERT_SIDE[f.path] : void 0;
|
|
@@ -14258,8 +14276,10 @@ OPTIONS
|
|
|
14258
14276
|
--remove-unrecorded (revert) REMOVE unrecorded values + DELETE unrecorded
|
|
14259
14277
|
added resources (never recorded; default: refuse —
|
|
14260
14278
|
record the ones that are right)
|
|
14261
|
-
--yes, -y skip
|
|
14262
|
-
|
|
14279
|
+
--yes, -y skip the write confirm AND the op multiselect — apply the
|
|
14280
|
+
FULL plan (revert) / skip the selection multiselect +
|
|
14281
|
+
overwrite notice, record ALL (record) / ignore ALL shown
|
|
14282
|
+
drift without the multiselect (ignore)
|
|
14263
14283
|
--help, -h --version, -v
|
|
14264
14284
|
|
|
14265
14285
|
Automation: check --fail / record --yes / ignore --yes / revert --yes (or
|