@go-to-k/cdkd 0.25.0 → 0.26.0

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
@@ -455,13 +455,19 @@ cdkd state resources MyStack --json # full JSON array
455
455
  cdkd state show MyStack
456
456
  cdkd state show MyStack --json # raw {state, lock} JSON
457
457
 
458
- # Orphan a stack from cdkd's state (does NOT delete AWS resources).
459
- # Synth-driven needs --app / cdk.json — same stack-pattern routing as deploy.
460
- cdkd orphan MyStack # confirmation prompt (y/N)
461
- cdkd orphan MyStack --yes
462
- cdkd orphan 'MyStage/*' --yes # display-path wildcard
463
-
464
- # State-driven counterpart (no CDK app needed — works against the bucket).
458
+ # Orphan one or more RESOURCES from cdkd's state (does NOT delete AWS resources).
459
+ # Per-resource, mirrors aws-cdk-cli's `cdk orphan --unstable=orphan`.
460
+ # Synth-driven needs --app / cdk.json. Construct paths look like the CDK
461
+ # `aws:cdk:path` tag (`<StackName>/<Path/To/Resource>`).
462
+ cdkd orphan MyStack/MyTable # confirmation prompt (y/N)
463
+ cdkd orphan MyStack/MyTable --yes
464
+ cdkd orphan MyStack/MyTable MyStack/MyBucket # multiple resources, same stack
465
+ cdkd orphan MyStack/MyTable --dry-run # print rewrite audit, no save
466
+ cdkd orphan MyStack/MyTable --force # also fall back to cached
467
+ # attributes when live fetch fails
468
+
469
+ # State-driven counterpart that orphans a WHOLE STACK's state record
470
+ # (no CDK app needed — works against the bucket).
465
471
  cdkd state orphan MyStack # confirmation prompt (y/N)
466
472
  cdkd state orphan MyStack --yes # skip confirmation
467
473
  cdkd state orphan StackA StackB --force # also bypass the locked-stack refusal
@@ -477,9 +483,21 @@ cdkd state destroy MyStack --region us-east-1
477
483
  > **`destroy` vs `orphan`** (matches aws-cdk-cli's new `cdk orphan`):
478
484
  > `destroy` deletes the AWS resources AND the state record. `orphan` deletes
479
485
  > ONLY the state record — AWS resources remain intact, just no longer
480
- > tracked by cdkd. Each has a synth-driven form (`cdkd destroy` / `cdkd
481
- > orphan`, needs the CDK app) and a state-driven form (`cdkd state destroy`
482
- > / `cdkd state orphan`, works on the bucket alone).
486
+ > tracked by cdkd.
487
+ >
488
+ > The two `orphan` variants now operate at different granularities:
489
+ >
490
+ > - `cdkd orphan <constructPath>...` — synth-driven, **per-resource**.
491
+ > Removes specific resources from a stack's state file and rewrites every
492
+ > sibling reference (Ref / Fn::GetAtt / Fn::Sub / dependencies) so the
493
+ > next deploy doesn't re-create the orphan or fail on a stale reference.
494
+ > Mirrors `cdk orphan --unstable=orphan`.
495
+ > - `cdkd state orphan <stack>...` — state-driven, **whole-stack**. Removes
496
+ > the entire state record for a stack from the bucket. Works without the
497
+ > CDK app.
498
+ >
499
+ > `cdkd destroy` (synth-driven, deletes AWS resources + state) and
500
+ > `cdkd state destroy` (state-driven, same effect) round out the matrix.
483
501
 
484
502
  ### Concurrency Options
485
503
 
@@ -508,17 +526,30 @@ Both `cdkd deploy` and `cdkd destroy` (including `cdkd state destroy`) enforce a
508
526
 
509
527
  | Option | Default | Description |
510
528
  | --- | --- | --- |
511
- | `--resource-warn-after <duration>` | `5m` | Warn when a single resource operation has been running longer than this. The live progress line is suffixed with `[taking longer than expected, Nm+]` and a `WARN` log line is emitted (printed above the live area in TTY mode, plain stderr otherwise). |
512
- | `--resource-timeout <duration>` | `30m` | Abort a single resource operation that exceeds this. The deploy / destroy fails with `ResourceTimeoutError` (wrapped in `ProvisioningError`) and the existing rollback / state-preservation path runs. |
529
+ | `--resource-warn-after <duration_or_type=duration>` | `5m` | Warn when a single resource operation has been running longer than this. The live progress line is suffixed with `[taking longer than expected, Nm+]` and a `WARN` log line is emitted (printed above the live area in TTY mode, plain stderr otherwise). Repeatable. |
530
+ | `--resource-timeout <duration_or_type=duration>` | `30m` | Abort a single resource operation that exceeds this. The deploy / destroy fails with `ResourceTimeoutError` (wrapped in `ProvisioningError`) and the existing rollback / state-preservation path runs. Repeatable. |
513
531
 
514
532
  Durations are written as `<number>s`, `<number>m`, or `<number>h` (e.g. `30s`, `90s`, `5m`, `1.5h`). Zero, negative, missing-unit, and unknown-unit values are rejected at parse time.
515
533
 
534
+ Both flags accept either form on each invocation:
535
+
536
+ - **Bare duration** (`30m`) sets the global default. The last bare value wins.
537
+ - **`TYPE=DURATION`** (`AWS::CloudFront::Distribution=1h`) adds a per-resource-type override that supersedes the global default for that type only.
538
+
539
+ `TYPE` must look like `AWS::Service::Resource`; malformed types are rejected at parse time. `warn < timeout` is enforced both globally and per-type — so `--resource-warn-after AWS::X=10m --resource-timeout AWS::X=5m` is a parse-time error.
540
+
516
541
  ```bash
517
542
  # Bump the per-resource budget to one hour (matches the Custom Resource provider's polling cap)
518
543
  cdkd deploy --resource-timeout 1h
519
544
 
520
545
  # Surface "still running" warnings sooner on a fast-feedback dev loop
521
546
  cdkd deploy --resource-warn-after 90s --resource-timeout 10m
547
+
548
+ # Keep the global default tight, raise it only for resources known to take longer
549
+ cdkd deploy \
550
+ --resource-timeout 30m \
551
+ --resource-timeout AWS::CloudFront::Distribution=1h \
552
+ --resource-timeout AWS::RDS::DBCluster=1h30m
522
553
  ```
523
554
 
524
555
  ### Why the default is 30m, not 1h
@@ -619,6 +650,13 @@ cdkd import MyStack --resource-mapping mapping.json
619
650
 
620
651
  # CDK CLI compat: inline JSON (handy for non-TTY CI scripts).
621
652
  cdkd import MyStack --resource-mapping-inline '{"MyBucket":"my-bucket-name"}'
653
+
654
+ # Capture cdkd's resolved logicalId→physicalId mapping for re-use.
655
+ # Combine with --auto (or no flags) to record the tag-based lookups.
656
+ cdkd import MyStack --record-resource-mapping ./mapping.json
657
+ # mapping.json after the run: { "MyBucket": "my-bucket-name", ... }
658
+ # Replay non-interactively in CI:
659
+ cdkd import MyStack --resource-mapping ./mapping.json --yes
622
660
  ```
623
661
 
624
662
  When at least one `--resource` flag (or a `--resource-mapping` /
@@ -695,8 +733,8 @@ table to predict behavior when migrating from `cdk import`.
695
733
  | Failure mode | Failed import rolls the changeset back; the stack is left unchanged. | Per-resource: `imported` / `skipped-not-found` / `skipped-no-impl` / `skipped-out-of-scope` / `failed` rows are summarized. State is written for whatever succeeded — but only after a confirmation prompt (or `--yes`), so a partial run is opt-in. To roll a partial import back, use `cdkd state orphan <stack>` (drops the state record only). |
696
734
  | Selective mode (`--resource-mapping <file>`) | Supported. Listed resources are imported; unlisted resources cause the changeset to fail. | Supported. Listed resources are imported; unlisted resources are reported as `out of scope` and left out of state (next `cdkd deploy` will CREATE them). |
697
735
  | Selective mode (`--resource <id>=<physical>` repeatable) | Not supported (upstream uses interactive prompts or a mapping file). | Supported as cdkd's CLI-friendly equivalent. |
698
- | `--resource-mapping-inline '<json>'` | Supported (use in non-TTY environments). | **Not supported.** Use `--resource <id>=<physical>` (repeatable) or `--resource-mapping <file>` instead. |
699
- | `--record-resource-mapping <file>` | Supported (writes the mapping the user typed at the prompt to a file for re-use). | **Not supported.** cdkd has no interactive prompt to record. |
736
+ | `--resource-mapping-inline '<json>'` | Supported (use in non-TTY environments). | Supported. Same shape as `--resource-mapping <file>` but supplied as a string — useful for non-TTY CI scripts that do not want a separate file. Mutually exclusive with `--resource-mapping`. |
737
+ | `--record-resource-mapping <file>` | Supported (writes the mapping the user typed at the prompt to a file for re-use). | Supported. Writes the resolved `{logicalId: physicalId}` map (covers explicit overrides AND cdkd's tag-based auto-lookup) to the file before the confirmation prompt. The file is produced even if the user says "no" or under `--dry-run`, so the resolved data is never thrown away. |
700
738
  | Interactive prompt for missing IDs | Default in TTY — prompts for every resource not covered by a mapping file. | **Not supported.** cdkd is non-interactive: missing logical IDs are looked up by `aws:cdk:path` tag in `auto` / `hybrid` modes, or skipped as `out of scope` in selective mode. The only prompt is the final "write state?" confirmation, which `--yes` skips. |
701
739
  | Typo'd logical ID | Aborts with a clear error before any AWS calls. | Aborts with a clear error before any AWS calls — checked against the synthesized template. |
702
740
  | Whole-stack tag-based import | **Not supported.** | **cdkd-specific.** With no flags, cdkd looks every resource up by its `aws:cdk:path` tag — the typical case for adopting a stack previously deployed by `cdk deploy`. |
@@ -712,8 +750,13 @@ table to predict behavior when migrating from `cdk import`.
712
750
 
713
751
  - If you script around `--resource-mapping <file>`: behavior matches.
714
752
  The file format (`{"LogicalId": "physical-id"}`) is the same.
715
- - If you script around `--resource-mapping-inline`: rewrite as
716
- repeated `--resource <id>=<physical>` flags, or write a temp file.
753
+ - If you script around `--resource-mapping-inline`: behavior matches.
754
+ The JSON shape is the same as `--resource-mapping <file>`.
755
+ - If you script around `--record-resource-mapping <file>`: behavior
756
+ matches. cdkd writes the resolved `{logicalId: physicalId}` map to
757
+ the file before the confirmation prompt — and even if the user says
758
+ "no" or under `--dry-run` — so you can capture cdkd's tag-based
759
+ auto-lookup result and replay it via `--resource-mapping` in CI.
717
760
  - If your workflow relies on the interactive prompt: rewrite as
718
761
  `--resource-mapping <file>`. cdkd will not prompt.
719
762
  - If you rely on atomic rollback: cdkd cannot offer that — its