cdk-real-drift 0.22.4 → 0.22.6

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
@@ -141,6 +141,28 @@ Each block above is one kind of finding, and neither needed a baseline:
141
141
  At the prompt you act on each finding: **record** it (accept and watch),
142
142
  **revert** it (undo the change), or **ignore** it (stop reporting).
143
143
 
144
+ ### Every kind of drift and how it prints
145
+
146
+ Those are just the two a first run can show. The full set, confirmed or
147
+ potential:
148
+
149
+ | label | drift | judged against | appears |
150
+ | ------------------------ | ----------------------------------------------------------------------------------------- | ---------------------------- | ------------------ |
151
+ | `[CFn-Declared Drift]` | a declared property whose live value differs | the deployed template | from the first run |
152
+ | `[CFn-Undeclared Drift]` | a live-only value changed out of band (the differentiator) | your `.cdkrd` baseline | after you `record` |
153
+ | `[Added Resource]` | a recorded [out-of-band resource](#added-out-of-band-resources) changed since the record | your `.cdkrd` baseline | after you `record` |
154
+ | `[Deleted]` | a declared resource, or an added one you recorded, deleted out of band (the most blatant) | the template / your baseline | from the first run |
155
+ | `[Potential Drift]` | unconfirmed live-only values (and unrecorded added resources) | nothing yet | until you `record` |
156
+
157
+ The first four are confirmed drift, the kind that fails CI (see
158
+ [In CI](#in-ci)); `[Potential Drift]`, being unconfirmed, never does: it waits
159
+ for your record / revert / ignore decision. Record it (next section) and it
160
+ leaves the report but **stays watched**: a later out-of-band change to that
161
+ value surfaces as confirmed `[CFn-Undeclared Drift]`, and a whole recorded
162
+ resource comes back as `[Added Resource]` if changed, or `[Deleted]` if
163
+ deleted. Everything else `check` prints is informational, not drift: it is
164
+ folded into a one-line `info:` footer and detailed in [Output](#output).
165
+
144
166
  ### Recording
145
167
 
146
168
  Recording snapshots those live-only values into a git-committed `.cdkrd` baseline,
@@ -163,6 +185,10 @@ result: 1 drift(s) (undeclared=1)
163
185
  ─────────────────────────────────
164
186
  ```
165
187
 
188
+ The same applies one level up: a whole out-of-band resource you've recorded
189
+ surfaces as **`[Added Resource]`** if its live model changes after the record
190
+ (see [Added out-of-band resources](#added-out-of-band-resources)).
191
+
166
192
  `record` covers live-only state only, not a `[CFn-Declared Drift]`; the other
167
193
  verbs are in [The model](#the-model-one-verb-you-run-three-it-offers).
168
194
 
@@ -250,20 +276,14 @@ undeployed code changes don't show up as drift by default. `--pre-deploy` invert
250
276
  that, checking live state against the freshly synthesized template (see
251
277
  [`--pre-deploy`](#--pre-deploy)).
252
278
 
253
- ### The kinds of drift
254
-
255
- Named so "declared" is never ambiguous (`CFn-declared` means **in the deployed
256
- template**, not your CDK code and not your `.cdkrd` baseline):
279
+ ### Naming and mechanics
257
280
 
258
- | term | source | how it's judged |
259
- | ------------------------------ | ------------------------------------ | ----------------------------------------------------------------------- |
260
- | **CFn-declared** | in the deployed template | vs the deployed template; drift from the first run, no baseline needed |
261
- | **CFn-undeclared** (live-only) | on the resource, not in the template | vs your `.cdkrd` baseline; the key differentiator |
262
- | **Added resource** | a whole resource not in the template | reconciled against the baseline like an undeclared property (see below) |
263
- | **Deleted** | in the template, gone live | the most blatant drift; always fails `--fail` |
264
-
265
- (`CFn-undeclared` is a template axis; `recorded` / `unrecorded` is a separate
266
- baseline-file axis: whether you've snapshotted that value yet.)
281
+ The kinds themselves, and the label each prints under, are the
282
+ [table in How to use](#every-kind-of-drift-and-how-it-prints). The names are
283
+ chosen so "declared" is never ambiguous: `CFn-declared` means **in the deployed
284
+ template**, not your CDK code and not your `.cdkrd` baseline. (`CFn-undeclared`
285
+ is a template axis; `recorded` / `unrecorded` is a separate baseline-file axis:
286
+ whether you've snapshotted that value yet.)
267
287
 
268
288
  The mechanics:
269
289
 
@@ -286,11 +306,12 @@ A whole child resource that exists live but isn't in your template (e.g. an API
286
306
  Gateway `ANY` method added on `/` via the console) is the resource-level sibling
287
307
  of an undeclared property, and is reconciled the same way against your baseline:
288
308
 
289
- | state | reported as |
290
- | --------------------------- | ---------------------------------------------- |
291
- | added, **not** recorded | **Potential Drift** (no baseline, unconfirmed) |
292
- | recorded, unchanged | suppressed |
293
- | recorded, **changed** since | failing drift |
309
+ | state | reported as |
310
+ | --------------------------- | --------------------------------------------------------------- |
311
+ | added, **not** recorded | **Potential Drift** (no baseline, unconfirmed) |
312
+ | recorded, unchanged | suppressed |
313
+ | recorded, **changed** since | failing drift (`[Added Resource]`) |
314
+ | recorded, **deleted** since | failing drift (`[Deleted]`: record keeps watching; detect-only) |
294
315
 
295
316
  `cdk drift` / CFn drift detection compare only template-declared resources, so an
296
317
  out-of-band addition is invisible to them. Decide it like any finding: `record`
@@ -657,8 +678,12 @@ info:
657
678
  run with --verbose for the list
658
679
  ```
659
680
 
660
- - **Drift tiers** (`deleted` / `declared` / `undeclared`) are always listed in
661
- full and drive the `--fail` exit. They are the point.
681
+ The table of every drift kind and its section label is up in
682
+ [How to use](#every-kind-of-drift-and-how-it-prints); the mechanics:
683
+
684
+ - The four **confirmed drift tiers** (`deleted` / `declared` / `undeclared` /
685
+ `added`) are always listed in full and drive the `--fail` exit. They are the
686
+ point.
662
687
  - **`[Potential Drift: N]`**: undeclared values with no baseline yet; cdkrd
663
688
  can't tell an intentional setting from an out-of-band change, so they're listed
664
689
  in full as _potential_ (unconfirmed) drift and don't drive the `--fail` exit;
package/dist/cli.js CHANGED
@@ -2528,6 +2528,10 @@ const KNOWN_DEFAULTS = {
2528
2528
  KeyUsage: "ENCRYPT_DECRYPT",
2529
2529
  Origin: "AWS_KMS"
2530
2530
  },
2531
+ "AWS::DLM::LifecyclePolicy": {
2532
+ RetainInterval: 7,
2533
+ CreateInterval: 1
2534
+ },
2531
2535
  "AWS::IAM::Group": { Path: "/" },
2532
2536
  "AWS::IAM::User": { Path: "/" },
2533
2537
  "AWS::IAM::InstanceProfile": { Path: "/" },
@@ -3739,6 +3743,7 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
3739
3743
  };
3740
3744
  const VALUE_INDEPENDENT_DEFAULT_NESTED_PATHS = {
3741
3745
  "AWS::Batch::ComputeEnvironment": new Set(["ComputeResources.DesiredvCpus"]),
3746
+ "AWS::DLM::LifecyclePolicy": new Set(["PolicyDetails.Schedules.*.CreateRule.Times"]),
3742
3747
  "AWS::AutoScaling::AutoScalingGroup": new Set(["Tags.*.ResourceId", "Tags.*.ResourceType"])
3743
3748
  };
3744
3749
  function isPhysicalIdSegment(value, physicalId) {
@@ -3918,14 +3923,14 @@ const ELB_TG_ATTRIBUTE_DEFAULTS_BY_PROTOCOL = {
3918
3923
  },
3919
3924
  UDP: {
3920
3925
  "stickiness.type": "source_ip",
3921
- "deregistration_delay.connection_termination.enabled": "false",
3926
+ "deregistration_delay.connection_termination.enabled": "true",
3922
3927
  "proxy_protocol_v2.enabled": "false",
3923
3928
  "target_health_state.unhealthy.connection_termination.enabled": "true",
3924
3929
  "target_health_state.unhealthy.draining_interval_seconds": "0"
3925
3930
  },
3926
3931
  TCP_UDP: {
3927
3932
  "stickiness.type": "source_ip",
3928
- "deregistration_delay.connection_termination.enabled": "false",
3933
+ "deregistration_delay.connection_termination.enabled": "true",
3929
3934
  "proxy_protocol_v2.enabled": "false",
3930
3935
  "target_health_state.unhealthy.connection_termination.enabled": "true",
3931
3936
  "target_health_state.unhealthy.draining_interval_seconds": "0"
@@ -11769,9 +11774,13 @@ const readDlmLifecyclePolicy = async ({ physicalId, declared, region }) => {
11769
11774
  if (str$1(p.State) !== void 0) model.State = p.State;
11770
11775
  if (str$1(p.ExecutionRoleArn) !== void 0) model.ExecutionRoleArn = p.ExecutionRoleArn;
11771
11776
  const details = p.PolicyDetails ?? {};
11772
- if (declared.PolicyDetails === void 0 && DLM_DEFAULT_POLICY_SHORTHAND.some((k) => declared[k] !== void 0)) {
11777
+ if (p.DefaultPolicy === true || declared.PolicyDetails === void 0 && DLM_DEFAULT_POLICY_SHORTHAND.some((k) => declared[k] !== void 0)) {
11773
11778
  for (const k of DLM_DEFAULT_POLICY_SHORTHAND) if (details[k] !== void 0) model[k] = details[k];
11774
11779
  } else if (Object.keys(details).length > 0) model.PolicyDetails = details;
11780
+ if (p.DefaultPolicy === true) {
11781
+ const rt = str$1(details.ResourceType);
11782
+ if (rt !== void 0) model.DefaultPolicy = rt;
11783
+ }
11775
11784
  const dlmTags = projectTagList(Object.entries(p.Tags ?? {}).map(([Key, Value]) => ({
11776
11785
  Key,
11777
11786
  Value
@@ -16919,7 +16928,7 @@ function report(rawFindings, header, opts = {}) {
16919
16928
  const tierSection = (tier, leadingBlank) => section(byTier(tier), TIER_NAMES[tier], TIER_NOTES[tier], tierStyle(tier), leadingBlank);
16920
16929
  log(style.header(`=== check: ${header} ===`));
16921
16930
  if (unrecordedShown.length > 0) {
16922
- log(style.undeclaredTier("No baseline yet — these live-only values can't be confirmed as drift. Record them right from this `cdkrd check` prompt, or run `cdkrd record`."));
16931
+ log(style.undeclaredTier(opts.hasBaseline ? "Not in your baseline — these live-only values are on resources record couldn't fully snapshot (see readGap/skipped in info:), so cdkrd can't confirm them as drift. Record to accept them." : "No baseline yet — these live-only values can't be confirmed as drift. Record them right from this `cdkrd check` prompt, or run `cdkrd record`."));
16923
16932
  log("");
16924
16933
  }
16925
16934
  let driftSections = 0;
@@ -17861,17 +17870,18 @@ const writeDlmLifecyclePolicy = async (ctx, ops) => {
17861
17870
  ...CLIENT_TIMEOUTS
17862
17871
  });
17863
17872
  const m = await desiredModel("AWS::DLM::LifecyclePolicy", ctx, ops);
17864
- let details = m.PolicyDetails;
17865
- if (details === void 0 && DLM_DEFAULT_POLICY_SHORTHAND.some((k) => m[k] !== void 0)) {
17866
- details = { ...(await c.send(new GetLifecyclePolicyCommand({ PolicyId: id }))).Policy?.PolicyDetails ?? {} };
17867
- for (const k of DLM_DEFAULT_POLICY_SHORTHAND) if (m[k] !== void 0) details[k] = m[k];
17873
+ const details = m.PolicyDetails;
17874
+ const shorthand = {};
17875
+ if (details === void 0) {
17876
+ for (const k of DLM_DEFAULT_POLICY_SHORTHAND) if (m[k] !== void 0) shorthand[k] = m[k];
17868
17877
  }
17869
17878
  await c.send(new UpdateLifecyclePolicyCommand({
17870
17879
  PolicyId: id,
17871
17880
  ...str(m.Description) !== void 0 && { Description: str(m.Description) },
17872
17881
  ...str(m.State) !== void 0 && { State: str(m.State) },
17873
17882
  ...str(m.ExecutionRoleArn) !== void 0 && { ExecutionRoleArn: str(m.ExecutionRoleArn) },
17874
- ...details !== void 0 && { PolicyDetails: details }
17883
+ ...details !== void 0 && { PolicyDetails: details },
17884
+ ...shorthand
17875
17885
  }));
17876
17886
  };
17877
17887
  const writeMetricFilter = async (ctx, ops) => {
@@ -19347,6 +19357,8 @@ const CC_REVERTABLE_DESPITE_READ_OVERRIDE = new Set([
19347
19357
  "AWS::EC2::EIP"
19348
19358
  ]);
19349
19359
  const REVERT_SET_DEFAULT_PATHS = new Set([
19360
+ "AWS::DLM::LifecyclePolicy\0RetainInterval",
19361
+ "AWS::DLM::LifecyclePolicy\0CreateInterval",
19350
19362
  "AWS::IAM::Role\0MaxSessionDuration",
19351
19363
  "AWS::IAM::Role\0Description",
19352
19364
  "AWS::Lambda::Alias\0Description",
@@ -22315,7 +22327,8 @@ async function runCheck(args) {
22315
22327
  code = jsonCode;
22316
22328
  } else code = report(reconciled, reportHeader, {
22317
22329
  verbose: a.verbose,
22318
- expandAtDefault: a.showAll
22330
+ expandAtDefault: a.showAll,
22331
+ ...a.showAll ? {} : { hasBaseline: baseline !== void 0 }
22319
22332
  });
22320
22333
  const hasUnrecorded = reconciled.some((f) => f.unrecorded === true);
22321
22334
  if (shouldOfferInteractiveResolve(a, {