@composurecdk/cloudwatch 0.8.4 → 0.8.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/dist/commonjs/alarm-threshold-basis.d.ts +71 -0
- package/dist/commonjs/alarm-threshold-basis.d.ts.map +1 -0
- package/dist/commonjs/alarm-threshold-basis.js +40 -0
- package/dist/commonjs/alarm-threshold-basis.js.map +1 -0
- package/dist/commonjs/index.d.ts +1 -0
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +3 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/esm/alarm-threshold-basis.d.ts +71 -0
- package/dist/esm/alarm-threshold-basis.d.ts.map +1 -0
- package/dist/esm/alarm-threshold-basis.js +37 -0
- package/dist/esm/alarm-threshold-basis.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +18 -6
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { IConstruct } from "constructs";
|
|
2
|
+
/**
|
|
3
|
+
* Inputs to {@link resolveAlarmThresholdBasis}.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam T - The input value's type (e.g. `Duration`, `number`).
|
|
6
|
+
*/
|
|
7
|
+
export interface AlarmThresholdBasisOptions<T> {
|
|
8
|
+
/** Construct to annotate when the alarm is skipped. */
|
|
9
|
+
scope: IConstruct;
|
|
10
|
+
/**
|
|
11
|
+
* The value the alarm threshold is derived from. May be `undefined` (the
|
|
12
|
+
* input was simply not configured) or an unresolved token (e.g. threaded
|
|
13
|
+
* through a `CfnParameter`).
|
|
14
|
+
*/
|
|
15
|
+
value: T | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Converts a known-resolved `value` into the numeric basis for the threshold
|
|
18
|
+
* (e.g. `(d) => d.toMilliseconds()`, or the identity for a raw number). Only
|
|
19
|
+
* invoked once `value` is confirmed present and resolved, so it is safe to
|
|
20
|
+
* call conversions that throw on tokens.
|
|
21
|
+
*/
|
|
22
|
+
resolve: (value: T) => number;
|
|
23
|
+
/**
|
|
24
|
+
* Predicate deciding whether `value` is an unresolved token. Defaults to
|
|
25
|
+
* {@link Token.isUnresolved}. Override for wrapper types that carry their own
|
|
26
|
+
* check rather than being a token directly — notably a CDK `Duration`, whose
|
|
27
|
+
* token state is exposed via `value.isUnresolved()`.
|
|
28
|
+
*/
|
|
29
|
+
isUnresolved?: (value: T) => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Stable warning identifier, also the handle callers pass to
|
|
32
|
+
* `Annotations.of(scope).acknowledgeWarning(...)` to suppress it. By
|
|
33
|
+
* convention `@composurecdk/<package>:<slug>`.
|
|
34
|
+
*/
|
|
35
|
+
warningId: string;
|
|
36
|
+
/**
|
|
37
|
+
* Human-readable name of the alarm being skipped, interpolated into the
|
|
38
|
+
* warning (e.g. `"Lambda duration"`). Phrase it to read after
|
|
39
|
+
* "Skipping the recommended ".
|
|
40
|
+
*/
|
|
41
|
+
alarmLabel: string;
|
|
42
|
+
/**
|
|
43
|
+
* How a caller can intentionally suppress the warning, interpolated into the
|
|
44
|
+
* warning's closing sentence (e.g. `"recommendedAlarms({ duration: false })"`).
|
|
45
|
+
*/
|
|
46
|
+
suppressHint: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolves the numeric basis for a derived-threshold alarm, short-circuiting
|
|
50
|
+
* when the basis cannot be known at synth time.
|
|
51
|
+
*
|
|
52
|
+
* Recommended alarms whose threshold is a function of a configured input (a
|
|
53
|
+
* percentage of a timeout, of a reserved-concurrency limit, etc.) can only be
|
|
54
|
+
* rendered when that input is concrete. When the input is an unresolved token —
|
|
55
|
+
* e.g. a value threaded through a `CfnParameter` — there is no number to derive
|
|
56
|
+
* from at synth time, and unit-converting it would either throw or silently
|
|
57
|
+
* produce a meaningless threshold. In that case this annotates `scope` with a
|
|
58
|
+
* standardized, acknowledgeable warning and returns `undefined`, signalling the
|
|
59
|
+
* caller to omit the alarm.
|
|
60
|
+
*
|
|
61
|
+
* Returns `undefined` (without warning) when `value` is `undefined`, since an
|
|
62
|
+
* unconfigured input is not a skipped guardrail. The escape hatch that disables
|
|
63
|
+
* the alarm entirely (e.g. `recommendedAlarms({ duration: false })`) belongs at
|
|
64
|
+
* the call site, ahead of this call.
|
|
65
|
+
*
|
|
66
|
+
* @returns The resolved numeric basis, or `undefined` when the alarm should be
|
|
67
|
+
* omitted.
|
|
68
|
+
* @see https://github.com/laazyj/composureCDK/issues/196
|
|
69
|
+
*/
|
|
70
|
+
export declare function resolveAlarmThresholdBasis<T>(opts: AlarmThresholdBasisOptions<T>): number | undefined;
|
|
71
|
+
//# sourceMappingURL=alarm-threshold-basis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alarm-threshold-basis.d.ts","sourceRoot":"","sources":["../../src/alarm-threshold-basis.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,0BAA0B,CAAC,CAAC;IAC3C,uDAAuD;IACvD,KAAK,EAAE,UAAU,CAAC;IAElB;;;;OAIG;IACH,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC;IAErB;;;;;OAKG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IAE9B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;IAErC;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAC1C,IAAI,EAAE,0BAA0B,CAAC,CAAC,CAAC,GAClC,MAAM,GAAG,SAAS,CAgBpB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveAlarmThresholdBasis = resolveAlarmThresholdBasis;
|
|
4
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the numeric basis for a derived-threshold alarm, short-circuiting
|
|
7
|
+
* when the basis cannot be known at synth time.
|
|
8
|
+
*
|
|
9
|
+
* Recommended alarms whose threshold is a function of a configured input (a
|
|
10
|
+
* percentage of a timeout, of a reserved-concurrency limit, etc.) can only be
|
|
11
|
+
* rendered when that input is concrete. When the input is an unresolved token —
|
|
12
|
+
* e.g. a value threaded through a `CfnParameter` — there is no number to derive
|
|
13
|
+
* from at synth time, and unit-converting it would either throw or silently
|
|
14
|
+
* produce a meaningless threshold. In that case this annotates `scope` with a
|
|
15
|
+
* standardized, acknowledgeable warning and returns `undefined`, signalling the
|
|
16
|
+
* caller to omit the alarm.
|
|
17
|
+
*
|
|
18
|
+
* Returns `undefined` (without warning) when `value` is `undefined`, since an
|
|
19
|
+
* unconfigured input is not a skipped guardrail. The escape hatch that disables
|
|
20
|
+
* the alarm entirely (e.g. `recommendedAlarms({ duration: false })`) belongs at
|
|
21
|
+
* the call site, ahead of this call.
|
|
22
|
+
*
|
|
23
|
+
* @returns The resolved numeric basis, or `undefined` when the alarm should be
|
|
24
|
+
* omitted.
|
|
25
|
+
* @see https://github.com/laazyj/composureCDK/issues/196
|
|
26
|
+
*/
|
|
27
|
+
function resolveAlarmThresholdBasis(opts) {
|
|
28
|
+
if (opts.value === undefined)
|
|
29
|
+
return undefined;
|
|
30
|
+
const isUnresolved = opts.isUnresolved ?? aws_cdk_lib_1.Token.isUnresolved;
|
|
31
|
+
if (isUnresolved(opts.value)) {
|
|
32
|
+
aws_cdk_lib_1.Annotations.of(opts.scope).addWarningV2(opts.warningId, `Skipping the recommended ${opts.alarmLabel} alarm: its threshold is derived from a ` +
|
|
33
|
+
`value that is an unresolved token and cannot be resolved to a concrete threshold at ` +
|
|
34
|
+
`synth time. Set a literal value, add the alarm explicitly via addAlarm() with a fixed ` +
|
|
35
|
+
`threshold, or suppress this warning with ${opts.suppressHint}.`);
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
return opts.resolve(opts.value);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=alarm-threshold-basis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alarm-threshold-basis.js","sourceRoot":"","sources":["../../src/alarm-threshold-basis.ts"],"names":[],"mappings":";;AA8EA,gEAkBC;AAhGD,6CAAiD;AAwDjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,0BAA0B,CACxC,IAAmC;IAEnC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAE/C,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,IAAI,mBAAK,CAAC,YAAY,CAAC;IAC7D,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,yBAAW,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,CACrC,IAAI,CAAC,SAAS,EACd,4BAA4B,IAAI,CAAC,UAAU,0CAA0C;YACnF,sFAAsF;YACtF,wFAAwF;YACxF,4CAA4C,IAAI,CAAC,YAAY,GAAG,CACnE,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export type { AlarmConfig, AlarmConfigDefaults } from "./alarm-config.js";
|
|
|
3
3
|
export type { AlarmDefinition, AlarmMetric } from "./alarm-definition.js";
|
|
4
4
|
export { AlarmDefinitionBuilder } from "./alarm-definition-builder.js";
|
|
5
5
|
export { type AlarmName, alarmName } from "./alarm-name.js";
|
|
6
|
+
export { type AlarmThresholdBasisOptions, resolveAlarmThresholdBasis, } from "./alarm-threshold-basis.js";
|
|
6
7
|
export { defaultAlarmName } from "./default-alarm-name.js";
|
|
7
8
|
export { createAlarms } from "./create-alarms.js";
|
|
8
9
|
export { resolveAlarmConfig, type ResolvedAlarmConfig } from "./resolve-alarm-config.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,YAAY,EACV,wBAAwB,EACxB,iBAAiB,EACjB,YAAY,GACb,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,yBAAyB,GAC/B,MAAM,iCAAiC,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,WAAW;;;;;CAGO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EACL,KAAK,0BAA0B,EAC/B,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,YAAY,EACV,wBAAwB,EACxB,iBAAiB,EACjB,YAAY,GACb,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,yBAAyB,GAC/B,MAAM,iCAAiC,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,WAAW;;;;;CAGO,CAAC"}
|
package/dist/commonjs/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.constraints = exports.alarmNamePolicy = exports.alarmActionsPolicy = exports.resolveAlarmConfig = exports.createAlarms = exports.defaultAlarmName = exports.alarmName = exports.AlarmDefinitionBuilder = void 0;
|
|
3
|
+
exports.constraints = exports.alarmNamePolicy = exports.alarmActionsPolicy = exports.resolveAlarmConfig = exports.createAlarms = exports.defaultAlarmName = exports.resolveAlarmThresholdBasis = exports.alarmName = exports.AlarmDefinitionBuilder = void 0;
|
|
4
4
|
const alarm_name_js_1 = require("./alarm-name.js");
|
|
5
5
|
var alarm_definition_builder_js_1 = require("./alarm-definition-builder.js");
|
|
6
6
|
Object.defineProperty(exports, "AlarmDefinitionBuilder", { enumerable: true, get: function () { return alarm_definition_builder_js_1.AlarmDefinitionBuilder; } });
|
|
7
7
|
var alarm_name_js_2 = require("./alarm-name.js");
|
|
8
8
|
Object.defineProperty(exports, "alarmName", { enumerable: true, get: function () { return alarm_name_js_2.alarmName; } });
|
|
9
|
+
var alarm_threshold_basis_js_1 = require("./alarm-threshold-basis.js");
|
|
10
|
+
Object.defineProperty(exports, "resolveAlarmThresholdBasis", { enumerable: true, get: function () { return alarm_threshold_basis_js_1.resolveAlarmThresholdBasis; } });
|
|
9
11
|
var default_alarm_name_js_1 = require("./default-alarm-name.js");
|
|
10
12
|
Object.defineProperty(exports, "defaultAlarmName", { enumerable: true, get: function () { return default_alarm_name_js_1.defaultAlarmName; } });
|
|
11
13
|
var create_alarms_js_1 = require("./create-alarms.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,mDAAoD;AAIpD,6EAAuE;AAA9D,qIAAA,sBAAsB,OAAA;AAC/B,iDAA4D;AAAnC,0GAAA,SAAS,OAAA;AAClC,iEAA2D;AAAlD,yHAAA,gBAAgB,OAAA;AACzB,uDAAkD;AAAzC,gHAAA,YAAY,OAAA;AACrB,qEAAyF;AAAhF,6HAAA,kBAAkB,OAAA;AAC3B,8EAAwE;AAA/D,6HAAA,kBAAkB,OAAA;AAM3B,wEAKyC;AAJvC,uHAAA,eAAe,OAAA;AAMjB;;;;;;GAMG;AACU,QAAA,WAAW,GAAG;IACzB,QAAQ,EAAE,EAAE,SAAS,EAAE,iCAAiB,EAAE;IAC1C,QAAQ,EAAE,EAAE;CACiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,mDAAoD;AAIpD,6EAAuE;AAA9D,qIAAA,sBAAsB,OAAA;AAC/B,iDAA4D;AAAnC,0GAAA,SAAS,OAAA;AAClC,uEAGoC;AADlC,sIAAA,0BAA0B,OAAA;AAE5B,iEAA2D;AAAlD,yHAAA,gBAAgB,OAAA;AACzB,uDAAkD;AAAzC,gHAAA,YAAY,OAAA;AACrB,qEAAyF;AAAhF,6HAAA,kBAAkB,OAAA;AAC3B,8EAAwE;AAA/D,6HAAA,kBAAkB,OAAA;AAM3B,wEAKyC;AAJvC,uHAAA,eAAe,OAAA;AAMjB;;;;;;GAMG;AACU,QAAA,WAAW,GAAG;IACzB,QAAQ,EAAE,EAAE,SAAS,EAAE,iCAAiB,EAAE;IAC1C,QAAQ,EAAE,EAAE;CACiB,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { IConstruct } from "constructs";
|
|
2
|
+
/**
|
|
3
|
+
* Inputs to {@link resolveAlarmThresholdBasis}.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam T - The input value's type (e.g. `Duration`, `number`).
|
|
6
|
+
*/
|
|
7
|
+
export interface AlarmThresholdBasisOptions<T> {
|
|
8
|
+
/** Construct to annotate when the alarm is skipped. */
|
|
9
|
+
scope: IConstruct;
|
|
10
|
+
/**
|
|
11
|
+
* The value the alarm threshold is derived from. May be `undefined` (the
|
|
12
|
+
* input was simply not configured) or an unresolved token (e.g. threaded
|
|
13
|
+
* through a `CfnParameter`).
|
|
14
|
+
*/
|
|
15
|
+
value: T | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Converts a known-resolved `value` into the numeric basis for the threshold
|
|
18
|
+
* (e.g. `(d) => d.toMilliseconds()`, or the identity for a raw number). Only
|
|
19
|
+
* invoked once `value` is confirmed present and resolved, so it is safe to
|
|
20
|
+
* call conversions that throw on tokens.
|
|
21
|
+
*/
|
|
22
|
+
resolve: (value: T) => number;
|
|
23
|
+
/**
|
|
24
|
+
* Predicate deciding whether `value` is an unresolved token. Defaults to
|
|
25
|
+
* {@link Token.isUnresolved}. Override for wrapper types that carry their own
|
|
26
|
+
* check rather than being a token directly — notably a CDK `Duration`, whose
|
|
27
|
+
* token state is exposed via `value.isUnresolved()`.
|
|
28
|
+
*/
|
|
29
|
+
isUnresolved?: (value: T) => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Stable warning identifier, also the handle callers pass to
|
|
32
|
+
* `Annotations.of(scope).acknowledgeWarning(...)` to suppress it. By
|
|
33
|
+
* convention `@composurecdk/<package>:<slug>`.
|
|
34
|
+
*/
|
|
35
|
+
warningId: string;
|
|
36
|
+
/**
|
|
37
|
+
* Human-readable name of the alarm being skipped, interpolated into the
|
|
38
|
+
* warning (e.g. `"Lambda duration"`). Phrase it to read after
|
|
39
|
+
* "Skipping the recommended ".
|
|
40
|
+
*/
|
|
41
|
+
alarmLabel: string;
|
|
42
|
+
/**
|
|
43
|
+
* How a caller can intentionally suppress the warning, interpolated into the
|
|
44
|
+
* warning's closing sentence (e.g. `"recommendedAlarms({ duration: false })"`).
|
|
45
|
+
*/
|
|
46
|
+
suppressHint: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolves the numeric basis for a derived-threshold alarm, short-circuiting
|
|
50
|
+
* when the basis cannot be known at synth time.
|
|
51
|
+
*
|
|
52
|
+
* Recommended alarms whose threshold is a function of a configured input (a
|
|
53
|
+
* percentage of a timeout, of a reserved-concurrency limit, etc.) can only be
|
|
54
|
+
* rendered when that input is concrete. When the input is an unresolved token —
|
|
55
|
+
* e.g. a value threaded through a `CfnParameter` — there is no number to derive
|
|
56
|
+
* from at synth time, and unit-converting it would either throw or silently
|
|
57
|
+
* produce a meaningless threshold. In that case this annotates `scope` with a
|
|
58
|
+
* standardized, acknowledgeable warning and returns `undefined`, signalling the
|
|
59
|
+
* caller to omit the alarm.
|
|
60
|
+
*
|
|
61
|
+
* Returns `undefined` (without warning) when `value` is `undefined`, since an
|
|
62
|
+
* unconfigured input is not a skipped guardrail. The escape hatch that disables
|
|
63
|
+
* the alarm entirely (e.g. `recommendedAlarms({ duration: false })`) belongs at
|
|
64
|
+
* the call site, ahead of this call.
|
|
65
|
+
*
|
|
66
|
+
* @returns The resolved numeric basis, or `undefined` when the alarm should be
|
|
67
|
+
* omitted.
|
|
68
|
+
* @see https://github.com/laazyj/composureCDK/issues/196
|
|
69
|
+
*/
|
|
70
|
+
export declare function resolveAlarmThresholdBasis<T>(opts: AlarmThresholdBasisOptions<T>): number | undefined;
|
|
71
|
+
//# sourceMappingURL=alarm-threshold-basis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alarm-threshold-basis.d.ts","sourceRoot":"","sources":["../../src/alarm-threshold-basis.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,0BAA0B,CAAC,CAAC;IAC3C,uDAAuD;IACvD,KAAK,EAAE,UAAU,CAAC;IAElB;;;;OAIG;IACH,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC;IAErB;;;;;OAKG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IAE9B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;IAErC;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAC1C,IAAI,EAAE,0BAA0B,CAAC,CAAC,CAAC,GAClC,MAAM,GAAG,SAAS,CAgBpB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Annotations, Token } from "aws-cdk-lib";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the numeric basis for a derived-threshold alarm, short-circuiting
|
|
4
|
+
* when the basis cannot be known at synth time.
|
|
5
|
+
*
|
|
6
|
+
* Recommended alarms whose threshold is a function of a configured input (a
|
|
7
|
+
* percentage of a timeout, of a reserved-concurrency limit, etc.) can only be
|
|
8
|
+
* rendered when that input is concrete. When the input is an unresolved token —
|
|
9
|
+
* e.g. a value threaded through a `CfnParameter` — there is no number to derive
|
|
10
|
+
* from at synth time, and unit-converting it would either throw or silently
|
|
11
|
+
* produce a meaningless threshold. In that case this annotates `scope` with a
|
|
12
|
+
* standardized, acknowledgeable warning and returns `undefined`, signalling the
|
|
13
|
+
* caller to omit the alarm.
|
|
14
|
+
*
|
|
15
|
+
* Returns `undefined` (without warning) when `value` is `undefined`, since an
|
|
16
|
+
* unconfigured input is not a skipped guardrail. The escape hatch that disables
|
|
17
|
+
* the alarm entirely (e.g. `recommendedAlarms({ duration: false })`) belongs at
|
|
18
|
+
* the call site, ahead of this call.
|
|
19
|
+
*
|
|
20
|
+
* @returns The resolved numeric basis, or `undefined` when the alarm should be
|
|
21
|
+
* omitted.
|
|
22
|
+
* @see https://github.com/laazyj/composureCDK/issues/196
|
|
23
|
+
*/
|
|
24
|
+
export function resolveAlarmThresholdBasis(opts) {
|
|
25
|
+
if (opts.value === undefined)
|
|
26
|
+
return undefined;
|
|
27
|
+
const isUnresolved = opts.isUnresolved ?? Token.isUnresolved;
|
|
28
|
+
if (isUnresolved(opts.value)) {
|
|
29
|
+
Annotations.of(opts.scope).addWarningV2(opts.warningId, `Skipping the recommended ${opts.alarmLabel} alarm: its threshold is derived from a ` +
|
|
30
|
+
`value that is an unresolved token and cannot be resolved to a concrete threshold at ` +
|
|
31
|
+
`synth time. Set a literal value, add the alarm explicitly via addAlarm() with a fixed ` +
|
|
32
|
+
`threshold, or suppress this warning with ${opts.suppressHint}.`);
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
return opts.resolve(opts.value);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=alarm-threshold-basis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alarm-threshold-basis.js","sourceRoot":"","sources":["../../src/alarm-threshold-basis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAwDjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,0BAA0B,CACxC,IAAmC;IAEnC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAE/C,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,IAAI,KAAK,CAAC,YAAY,CAAC;IAC7D,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,CACrC,IAAI,CAAC,SAAS,EACd,4BAA4B,IAAI,CAAC,UAAU,0CAA0C;YACnF,sFAAsF;YACtF,wFAAwF;YACxF,4CAA4C,IAAI,CAAC,YAAY,GAAG,CACnE,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export type { AlarmConfig, AlarmConfigDefaults } from "./alarm-config.js";
|
|
|
3
3
|
export type { AlarmDefinition, AlarmMetric } from "./alarm-definition.js";
|
|
4
4
|
export { AlarmDefinitionBuilder } from "./alarm-definition-builder.js";
|
|
5
5
|
export { type AlarmName, alarmName } from "./alarm-name.js";
|
|
6
|
+
export { type AlarmThresholdBasisOptions, resolveAlarmThresholdBasis, } from "./alarm-threshold-basis.js";
|
|
6
7
|
export { defaultAlarmName } from "./default-alarm-name.js";
|
|
7
8
|
export { createAlarms } from "./create-alarms.js";
|
|
8
9
|
export { resolveAlarmConfig, type ResolvedAlarmConfig } from "./resolve-alarm-config.js";
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,YAAY,EACV,wBAAwB,EACxB,iBAAiB,EACjB,YAAY,GACb,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,yBAAyB,GAC/B,MAAM,iCAAiC,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,WAAW;;;;;CAGO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EACL,KAAK,0BAA0B,EAC/B,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,YAAY,EACV,wBAAwB,EACxB,iBAAiB,EACjB,YAAY,GACb,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,yBAAyB,GAC/B,MAAM,iCAAiC,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,WAAW;;;;;CAGO,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { validateAlarmName } from "./alarm-name.js";
|
|
2
2
|
export { AlarmDefinitionBuilder } from "./alarm-definition-builder.js";
|
|
3
3
|
export { alarmName } from "./alarm-name.js";
|
|
4
|
+
export { resolveAlarmThresholdBasis, } from "./alarm-threshold-basis.js";
|
|
4
5
|
export { defaultAlarmName } from "./default-alarm-name.js";
|
|
5
6
|
export { createAlarms } from "./create-alarms.js";
|
|
6
7
|
export { resolveAlarmConfig } from "./resolve-alarm-config.js";
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAkB,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAA4B,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAMxE,OAAO,EACL,eAAe,GAIhB,MAAM,iCAAiC,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,EAAE,SAAS,EAAE,iBAAiB,EAAE;IAC1C,QAAQ,EAAE,EAAE;CACiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAkB,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAEL,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAA4B,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAMxE,OAAO,EACL,eAAe,GAIhB,MAAM,iCAAiC,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,EAAE,SAAS,EAAE,iBAAiB,EAAE;IAC1C,QAAQ,EAAE,EAAE;CACiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composurecdk/cloudwatch",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
4
4
|
"description": "Composable CloudWatch alarm primitives for composureCDK resource packages",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,7 +20,19 @@
|
|
|
20
20
|
"test": "vitest run --passWithNoTests",
|
|
21
21
|
"test:watch": "vitest"
|
|
22
22
|
},
|
|
23
|
-
"keywords": [
|
|
23
|
+
"keywords": [
|
|
24
|
+
"aws",
|
|
25
|
+
"cdk",
|
|
26
|
+
"aws-cdk",
|
|
27
|
+
"infrastructure-as-code",
|
|
28
|
+
"iac",
|
|
29
|
+
"composurecdk",
|
|
30
|
+
"cloudwatch",
|
|
31
|
+
"alarm",
|
|
32
|
+
"monitoring",
|
|
33
|
+
"metrics",
|
|
34
|
+
"observability"
|
|
35
|
+
],
|
|
24
36
|
"author": "Jason Duffett (https://github.com/laazyj)",
|
|
25
37
|
"license": "MIT",
|
|
26
38
|
"publishConfig": {
|
|
@@ -38,15 +50,15 @@
|
|
|
38
50
|
},
|
|
39
51
|
"peerDependencies": {
|
|
40
52
|
"@composurecdk/cloudformation": "^0.8.0",
|
|
41
|
-
"aws-cdk-lib": "^2.
|
|
53
|
+
"aws-cdk-lib": "^2.93.0",
|
|
42
54
|
"constructs": "^10.0.0"
|
|
43
55
|
},
|
|
44
56
|
"devDependencies": {
|
|
45
|
-
"@types/node": "^25.9.
|
|
46
|
-
"aws-cdk-lib": "^2.
|
|
57
|
+
"@types/node": "^25.9.3",
|
|
58
|
+
"aws-cdk-lib": "^2.258.1",
|
|
47
59
|
"constructs": "^10.6.0",
|
|
48
60
|
"typescript": "^6.0.3",
|
|
49
|
-
"vitest": "^4.1.
|
|
61
|
+
"vitest": "^4.1.8"
|
|
50
62
|
},
|
|
51
63
|
"exports": {
|
|
52
64
|
"./package.json": "./package.json",
|