cdk-real-drift 0.4.23 → 0.4.25

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 CHANGED
@@ -368,28 +368,31 @@ CI (with `--yes`).
368
368
  leave cells natural-width. Don't chase pixel alignment at the cost of a
369
369
  readable diff. -->
370
370
 
371
- | option | meaning |
372
- | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
373
- | `--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 AWS-CLI/cdk region chain — the active profile's region, then the `[default]` profile's region, then EC2 IMDS |
374
- | `--profile <p>` | AWS profile (else `$AWS_PROFILE`, else `$AWS_DEFAULT_PROFILE` — same order `aws` and `cdk` use) |
375
- | `-a, --app <cmd\|cdk.out>` | CDK app command or pre-synthesized assembly dir (or `$CDKRD_APP` / cdk.json `"app"`); stack auto-discovery + construct paths |
376
- | `-c, --context key=value` | context for synth (repeatable; cdk.json is the base layer) |
377
- | `--all` | target every stack the app defines (the default when no `<stack>` is named; overrides any positional names) |
378
- | `--json` | machine-readable output (see [JSON contract](#json-output-contract)) |
379
- | `--fail` | (check) exit 1 on drift and never prompt; for scripts/CI. Without it, check reports drift but exits 0 |
380
- | `--strict` | (check) exit 1 when coverage is incomplete. A coverage gap is always surfaced loudly; `--strict` makes it CI-failing. Orthogonal to `--fail` |
381
- | `--show-all` | (check) inventory mode: show all current undeclared state, ignoring the baseline |
382
- | `--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 |
383
- | `--pre-deploy` | (check) compare live vs the LOCAL synth template: the declared drift your next `cdk deploy` would silently overwrite |
384
- | `--undeclared-only` | (check) undeclared drift only: pair cdkrd with `cdk drift` for the declared side |
385
- | `--declared-only` | (check) declared drift vs the deployed template only (undeclared tier skipped; baseline untouched). Not `--pre-deploy` |
386
- | `--dry-run` | (revert) print the plan; make no changes |
387
- | `--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`) |
388
- | `--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 |
389
- | `--yes` / `-y` | skip confirmations (revert apply; record records all without the multiselect) |
371
+ | option | meaning |
372
+ | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
373
+ | `--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 AWS-CLI/cdk region chain — the active profile's region, then the `[default]` profile's region, then EC2 IMDS |
374
+ | `--profile <p>` | AWS profile (else `$AWS_PROFILE`, else `$AWS_DEFAULT_PROFILE` — same order `aws` and `cdk` use) |
375
+ | `-a, --app <cmd\|cdk.out>` | CDK app command or pre-synthesized assembly dir (or `$CDKRD_APP` / cdk.json `"app"`); stack auto-discovery + construct paths |
376
+ | `-c, --context key=value` | context for synth (repeatable; cdk.json is the base layer) |
377
+ | `--all` | target every stack the app defines (the default when no `<stack>` is named; overrides any positional names) |
378
+ | `--json` | machine-readable output (see [JSON contract](#json-output-contract)) |
379
+ | `--fail` | (check) exit 1 on drift and never prompt; for scripts/CI. Without it, check reports drift but exits 0 |
380
+ | `--strict` | (check) exit 1 when coverage is incomplete. A coverage gap is always surfaced loudly; `--strict` makes it CI-failing. Orthogonal to `--fail` |
381
+ | `--show-all` | (check) inventory mode: show all current undeclared state, ignoring the baseline |
382
+ | `--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. `-v` means `--verbose` **inside a verb** (`check -v`); a bare `cdkrd -v` (no verb) prints the version |
383
+ | `--pre-deploy` | (check) compare live vs the LOCAL synth template: the declared drift your next `cdk deploy` would silently overwrite |
384
+ | `--undeclared-only` | (check) undeclared drift only: pair cdkrd with `cdk drift` for the declared side |
385
+ | `--declared-only` | (check) declared drift vs the deployed template only (undeclared tier skipped; baseline untouched). Not `--pre-deploy` |
386
+ | `--dry-run` | (revert) print the plan; make no changes |
387
+ | `--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`). The DURATION is **inline-only** (`--wait=5m`); a separate `--wait 5m` is not read |
388
+ | `--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 |
389
+ | `--yes` / `-y` | skip confirmations (revert apply; record records all without the multiselect) |
390
390
 
391
391
  Unknown options (`--apq`) and options missing their value (`--app` at the end of
392
392
  the line) are errors (exit `2`): a typo'd flag never silently becomes a stack name.
393
+ The three `check` scope flags — `--pre-deploy`, `--undeclared-only`, and
394
+ `--declared-only` — are **mutually exclusive**; passing two of them is an exit-`2`
395
+ error (they select which comparison runs, so a combination is contradictory).
393
396
 
394
397
  ### Interactive prompts (TTY only, CI is never prompted)
395
398
 
package/dist/cli.js CHANGED
@@ -3853,7 +3853,8 @@ function restrictYaml11Tags(baseTags) {
3853
3853
  }
3854
3854
  const CFN_YAML_PARSE_OPTIONS = {
3855
3855
  schema: "yaml-1.1",
3856
- customTags: restrictYaml11Tags
3856
+ customTags: restrictYaml11Tags,
3857
+ uniqueKeys: false
3857
3858
  };
3858
3859
  function detectTemplateFormat(text) {
3859
3860
  const trimmed = (text.charCodeAt(0) === 65279 ? text.slice(1) : text).trimStart();
@@ -9651,7 +9652,10 @@ const CC_IDENTIFIER_ADAPTERS = {
9651
9652
  const ruleName = pid.slice(bar + 1);
9652
9653
  const busArn = declared.EventBusName;
9653
9654
  if (typeof busArn === "string" && busArn.includes(":event-bus/")) return `${busArn.replace(":event-bus/", ":rule/")}/${ruleName}`;
9654
- if (region && account) return `arn:${region.startsWith("cn-") ? "aws-cn" : region.startsWith("us-gov-") ? "aws-us-gov" : "aws"}:events:${region}:${account}:rule/${busName}/${ruleName}`;
9655
+ if (region && account) {
9656
+ const { partition } = partitionForRegion(region);
9657
+ return `arn:${partition}:events:${region}:${account}:rule/${busName}/${ruleName}`;
9658
+ }
9655
9659
  }
9656
9660
  };
9657
9661
  function scalingPolicyComposite(pid, declared) {
@@ -13117,6 +13121,7 @@ function toPatchDocument(item) {
13117
13121
  //#region src/revert/apply.ts
13118
13122
  const POLL_INTERVAL_MS = 2e3;
13119
13123
  const TIMEOUT_MS = 900 * 1e3;
13124
+ const MAX_POLL_READ_FAILURES = 10;
13120
13125
  function isAlreadyGone(e) {
13121
13126
  const o = e ?? {};
13122
13127
  const name = typeof o.name === "string" ? o.name : "";
@@ -13125,15 +13130,18 @@ function isAlreadyGone(e) {
13125
13130
  return m.includes("not found") || m.includes("does not exist") || m.includes("notfound");
13126
13131
  }
13127
13132
  const sleep$1 = (ms) => new Promise((r) => setTimeout(r, ms));
13128
- async function pollToCompletion(cc, first) {
13133
+ async function pollToCompletion(cc, first, poll = {}) {
13134
+ const doSleep = poll.sleep ?? sleep$1;
13135
+ const clock = poll.now ?? Date.now;
13129
13136
  let event = first;
13130
13137
  const token = event?.RequestToken;
13131
13138
  if (!token) return {
13132
13139
  ok: false,
13133
13140
  error: "no request token returned"
13134
13141
  };
13135
- const deadline = Date.now() + TIMEOUT_MS;
13136
- while (Date.now() < deadline) {
13142
+ const deadline = clock() + TIMEOUT_MS;
13143
+ let pollFailures = 0;
13144
+ while (clock() < deadline) {
13137
13145
  const status = event?.OperationStatus;
13138
13146
  if (status === "SUCCESS") return { ok: true };
13139
13147
  if (status === "FAILED" || status === "CANCEL_COMPLETE") {
@@ -13144,8 +13152,21 @@ async function pollToCompletion(cc, first) {
13144
13152
  error: code && !msg.includes(code) ? `${code}: ${msg}` : msg
13145
13153
  };
13146
13154
  }
13147
- await sleep$1(POLL_INTERVAL_MS);
13148
- event = (await cc.send(new GetResourceRequestStatusCommand({ RequestToken: token }))).ProgressEvent;
13155
+ await doSleep(POLL_INTERVAL_MS);
13156
+ try {
13157
+ event = (await cc.send(new GetResourceRequestStatusCommand({ RequestToken: token }))).ProgressEvent;
13158
+ pollFailures = 0;
13159
+ } catch (e) {
13160
+ const text = errorText(e);
13161
+ if (!classifyTransient(text).transient) return {
13162
+ ok: false,
13163
+ error: text
13164
+ };
13165
+ if (++pollFailures >= MAX_POLL_READ_FAILURES) return {
13166
+ ok: false,
13167
+ error: `unable to confirm Cloud Control request status after ${MAX_POLL_READ_FAILURES} poll attempts (mutation NOT resent, to avoid a duplicate write)`
13168
+ };
13169
+ }
13149
13170
  }
13150
13171
  return {
13151
13172
  ok: false,
@@ -13159,7 +13180,7 @@ async function applyRevertItem(cc, item, identifier = item.physicalId, retry = {
13159
13180
  TypeName: item.resourceType,
13160
13181
  Identifier: identifier,
13161
13182
  PatchDocument: toPatchDocument(item)
13162
- }))).ProgressEvent);
13183
+ }))).ProgressEvent, retry);
13163
13184
  } catch (e) {
13164
13185
  return {
13165
13186
  ok: false,
@@ -13199,7 +13220,7 @@ async function applyRevertDelete(cc, item, identifier = item.physicalId, retry =
13199
13220
  const result = await pollToCompletion(cc, (await cc.send(new DeleteResourceCommand({
13200
13221
  TypeName: item.resourceType,
13201
13222
  Identifier: identifier
13202
- }))).ProgressEvent);
13223
+ }))).ProgressEvent, retry);
13203
13224
  if (!result.ok && isAlreadyGone({ message: result.error })) return { ok: true };
13204
13225
  return result;
13205
13226
  } catch (e) {
@@ -15427,28 +15448,34 @@ OPTIONS
15427
15448
  resource skipped (unread) or a nested stack not
15428
15449
  recursed into. A loud coverage warning always prints;
15429
15450
  --strict makes it CI-failing. Orthogonal to --fail
15430
- --show-all inventory mode: show ALL current undeclared state
15431
- (not just changes since record)
15451
+ --show-all (check) inventory mode: show ALL current undeclared
15452
+ state (not just changes since record)
15432
15453
  --verbose (check) expand informational tiers / (revert) the
15433
- NOT-revertable summary to full per-finding lists
15454
+ NOT-revertable summary to full per-finding lists /
15455
+ (record) itemize nested sub-keys in the multiselect
15434
15456
  --pre-deploy (check) compare live state vs the LOCAL synth template
15435
15457
  — the declared drift your next deploy would overwrite
15436
15458
  --undeclared-only (check) undeclared drift only — pair cdkrd with
15437
15459
  \`cdk drift\` / CFn drift detection for the declared side
15438
15460
  --declared-only (check) declared drift vs the DEPLOYED template only
15439
15461
  (undeclared tier skipped; baseline untouched)
15462
+ (--pre-deploy / --undeclared-only / --declared-only are
15463
+ MUTUALLY EXCLUSIVE — passing two is an exit-2 error)
15440
15464
  --dry-run (revert) print the plan; make no changes
15441
15465
  --wait[=DURATION] (revert) on a transient "resource is mid-update" error
15442
15466
  (e.g. RSLVR-00705) keep retrying until it settles, up to
15443
- DURATION (default 10m; e.g. --wait=5m, --wait=90s)
15444
- --remove-unrecorded (revert) REMOVE unrecorded values + DELETE unrecorded
15445
- added resources (never recorded; default: refuse —
15446
- record the ones that are right)
15467
+ DURATION (default 10m; e.g. --wait=5m, --wait=90s). The
15468
+ DURATION is INLINE-only (--wait=5m); a separate --wait 5m
15469
+ is NOT read (5m would be taken as a stack name)
15470
+ --remove-unrecorded (revert, and check for its inline revert) REMOVE unrecorded
15471
+ values + DELETE unrecorded added resources (never recorded;
15472
+ default: refuse — record the ones that are right)
15447
15473
  --yes, -y skip the write confirm AND the op multiselect — apply the
15448
15474
  FULL plan (revert) / skip the selection multiselect +
15449
15475
  overwrite notice, record ALL (record) / ignore ALL shown
15450
15476
  drift without the multiselect (ignore)
15451
- --help, -h --version, -v
15477
+ --help, -h --version, -v (bare \`cdkrd -v\` prints the version; inside a verb,
15478
+ \`-v\` is the short alias for --verbose, e.g. check -v)
15452
15479
 
15453
15480
  Automation: check --fail / record --yes / ignore --yes / revert --yes (or
15454
15481
  --dry-run); non-TTY runs never prompt.