@composurecdk/route53 0.4.5 → 0.4.7
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 +113 -2
- package/dist/defaults.d.ts +15 -0
- package/dist/defaults.d.ts.map +1 -1
- package/dist/defaults.js +18 -0
- package/dist/defaults.js.map +1 -1
- package/dist/health-check-alarm-builder.d.ts +130 -0
- package/dist/health-check-alarm-builder.d.ts.map +1 -0
- package/dist/health-check-alarm-builder.js +126 -0
- package/dist/health-check-alarm-builder.js.map +1 -0
- package/dist/health-check-alarm-config.d.ts +39 -0
- package/dist/health-check-alarm-config.d.ts.map +1 -0
- package/dist/health-check-alarm-config.js +2 -0
- package/dist/health-check-alarm-config.js.map +1 -0
- package/dist/health-check-alarm-defaults.d.ts +13 -0
- package/dist/health-check-alarm-defaults.d.ts.map +1 -0
- package/dist/health-check-alarm-defaults.js +26 -0
- package/dist/health-check-alarm-defaults.js.map +1 -0
- package/dist/health-check-alarms.d.ts +15 -0
- package/dist/health-check-alarms.d.ts.map +1 -0
- package/dist/health-check-alarms.js +42 -0
- package/dist/health-check-alarms.js.map +1 -0
- package/dist/health-check-builder.d.ts +100 -0
- package/dist/health-check-builder.d.ts.map +1 -0
- package/dist/health-check-builder.js +48 -0
- package/dist/health-check-builder.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -92,9 +92,120 @@ The defaults are exported as `HOSTED_ZONE_DEFAULTS`, `A_RECORD_DEFAULTS`, `AAAA_
|
|
|
92
92
|
|
|
93
93
|
[^alias]: AWS ignores TTL on alias records and CDK emits a warning when one is set, so `A`, `AAAA`, and `HTTPS` builders skip the default TTL whenever the target is an alias.
|
|
94
94
|
|
|
95
|
-
##
|
|
95
|
+
## Health Check Builder
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
```ts
|
|
98
|
+
import { HealthCheckType } from "aws-cdk-lib/aws-route53";
|
|
99
|
+
import { createHealthCheckBuilder } from "@composurecdk/route53";
|
|
100
|
+
|
|
101
|
+
createHealthCheckBuilder()
|
|
102
|
+
.type(HealthCheckType.HTTPS)
|
|
103
|
+
.fqdn("api.example.com")
|
|
104
|
+
.resourcePath("/health")
|
|
105
|
+
.build(stack, "ApiHealthCheck");
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Every [HealthCheckProps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_route53.HealthCheckProps.html) property is available as a fluent setter on the builder.
|
|
109
|
+
|
|
110
|
+
### Health-check defaults
|
|
111
|
+
|
|
112
|
+
| Property | Default | Rationale |
|
|
113
|
+
| ------------------ | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
114
|
+
| `failureThreshold` | `3` | AWS guidance — three consecutive failures avoids flapping from transient endpoint hiccups. |
|
|
115
|
+
| `requestInterval` | `Duration.seconds(30)` | Standard health check; matches the CDK default. |
|
|
116
|
+
| `measureLatency` | `true` | Per-region latency visibility on the Health Checks console; aligns with the Well-Architected operational-excellence pillar. Set `.measureLatency(false)` to opt out (small cost saving). |
|
|
117
|
+
|
|
118
|
+
Exported as `HEALTH_CHECK_DEFAULTS` for visibility and testing.
|
|
119
|
+
|
|
120
|
+
### Recommended Alarms
|
|
121
|
+
|
|
122
|
+
The builder creates the [AWS-recommended](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Route53) `HealthCheckStatus` alarm by default. No alarm actions are configured — access alarms from the build result to add SNS topics or other actions, or use [`alarmActionsPolicy`](../cloudwatch/README.md#alarm-actions-policy) for stack-wide wiring.
|
|
123
|
+
|
|
124
|
+
| Alarm | Metric | Default threshold |
|
|
125
|
+
| ------------------- | ------------------------------------- | ----------------- |
|
|
126
|
+
| `healthCheckStatus` | HealthCheckStatus (Minimum, 1 minute) | `< 1` |
|
|
127
|
+
|
|
128
|
+
`treatMissingData` defaults to `breaching`: missing datapoints are treated as unhealthy, matching the AWS example. This guards against the metric stopping emission while downstream systems still depend on the health check.
|
|
129
|
+
|
|
130
|
+
The defaults are exported as `HEALTH_CHECK_ALARM_DEFAULTS` for visibility and testing:
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
import { HEALTH_CHECK_ALARM_DEFAULTS } from "@composurecdk/route53";
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### Customising thresholds
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
createHealthCheckBuilder()
|
|
140
|
+
.type(HealthCheckType.HTTPS)
|
|
141
|
+
.fqdn("api.example.com")
|
|
142
|
+
.recommendedAlarms({ healthCheckStatus: { evaluationPeriods: 2 } });
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### Disabling alarms
|
|
146
|
+
|
|
147
|
+
Disable the recommended alarm with `recommendedAlarms({ healthCheckStatus: false })`, or disable all recommended alarms with `recommendedAlarms(false)`. Custom alarms attached via `addAlarm` are unaffected by either form.
|
|
148
|
+
|
|
149
|
+
#### Custom alarms
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import { Metric } from "aws-cdk-lib/aws-cloudwatch";
|
|
153
|
+
|
|
154
|
+
createHealthCheckBuilder()
|
|
155
|
+
.type(HealthCheckType.HTTPS)
|
|
156
|
+
.fqdn("api.example.com")
|
|
157
|
+
.addAlarm("connectionTime", (a) =>
|
|
158
|
+
a
|
|
159
|
+
.metric(
|
|
160
|
+
(hc) =>
|
|
161
|
+
new Metric({
|
|
162
|
+
namespace: "AWS/Route53",
|
|
163
|
+
metricName: "ConnectionTime",
|
|
164
|
+
dimensionsMap: { HealthCheckId: hc.healthCheckId },
|
|
165
|
+
statistic: "Average",
|
|
166
|
+
}),
|
|
167
|
+
)
|
|
168
|
+
.threshold(2000)
|
|
169
|
+
.greaterThan(),
|
|
170
|
+
);
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### Applying alarm actions
|
|
174
|
+
|
|
175
|
+
No alarm actions are configured by default. Wire SNS or other actions via `alarmActionsPolicy` (or an `afterBuild` hook) — for cross-region deployments, the policy applied to the `us-east-1` monitoring stack covers both recommended and custom alarms.
|
|
176
|
+
|
|
177
|
+
### Cross-region: `AWS/Route53` metrics live in `us-east-1` only
|
|
178
|
+
|
|
179
|
+
Route 53 publishes its CloudWatch metrics in `us-east-1` regardless of where the health check is created. CloudWatch alarms are regional, so an alarm in any other region will never receive data. The combined builder emits a synth-time warning (`@composurecdk/route53:alarm-region`) when used outside `us-east-1`, but the better approach is to route the alarm into a `us-east-1` stack via `createHealthCheckAlarmBuilder` and `compose().withStacks()`:
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
import { compose, ref } from "@composurecdk/core";
|
|
183
|
+
import { HealthCheckType } from "aws-cdk-lib/aws-route53";
|
|
184
|
+
import {
|
|
185
|
+
createHealthCheckBuilder,
|
|
186
|
+
createHealthCheckAlarmBuilder,
|
|
187
|
+
type HealthCheckBuilderResult,
|
|
188
|
+
} from "@composurecdk/route53";
|
|
189
|
+
|
|
190
|
+
compose(
|
|
191
|
+
{
|
|
192
|
+
api: createHealthCheckBuilder()
|
|
193
|
+
.type(HealthCheckType.HTTPS)
|
|
194
|
+
.fqdn("api.example.com")
|
|
195
|
+
.recommendedAlarms(false), // suppress alarms in the api's own stack
|
|
196
|
+
|
|
197
|
+
apiAlarms: createHealthCheckAlarmBuilder().healthCheck(ref<HealthCheckBuilderResult>("api")),
|
|
198
|
+
},
|
|
199
|
+
{ api: [], apiAlarms: ["api"] },
|
|
200
|
+
)
|
|
201
|
+
.withStacks({
|
|
202
|
+
api: appStack, // any region — Route 53 health checks are global
|
|
203
|
+
apiAlarms: monitoringStack, // us-east-1 — where AWS/Route53 metrics live
|
|
204
|
+
})
|
|
205
|
+
.build(app, "App");
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Set `crossRegionReferences: true` on both stacks so CDK can export the `HealthCheckId` from the app stack and import it in the alarm stack. The same pattern is documented for CloudFront alarms ([#58](https://github.com/laazyj/composureCDK/pull/58)) and codified in [ADR-0004](../../docs/adr/0004-split-alarm-builder-for-fixed-region-metrics.md).
|
|
98
209
|
|
|
99
210
|
## Zone DSL
|
|
100
211
|
|
package/dist/defaults.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type { NsRecordBuilderProps } from "./ns-record-builder.js";
|
|
|
10
10
|
import type { DsRecordBuilderProps } from "./ds-record-builder.js";
|
|
11
11
|
import type { HttpsRecordBuilderProps } from "./https-record-builder.js";
|
|
12
12
|
import type { SvcbRecordBuilderProps } from "./svcb-record-builder.js";
|
|
13
|
+
import type { HealthCheckBuilderProps } from "./health-check-builder.js";
|
|
13
14
|
/**
|
|
14
15
|
* Secure, AWS-recommended defaults applied to every public hosted zone built
|
|
15
16
|
* with {@link createHostedZoneBuilder}. Each property can be individually
|
|
@@ -75,4 +76,18 @@ export declare const HTTPS_RECORD_DEFAULTS: Partial<HttpsRecordBuilderProps>;
|
|
|
75
76
|
* Defaults for {@link createSvcbRecordBuilder}. Overridable via the fluent API.
|
|
76
77
|
*/
|
|
77
78
|
export declare const SVCB_RECORD_DEFAULTS: Partial<SvcbRecordBuilderProps>;
|
|
79
|
+
/**
|
|
80
|
+
* Defaults for {@link createHealthCheckBuilder}. Overridable via the fluent API.
|
|
81
|
+
*
|
|
82
|
+
* `failureThreshold` and `requestInterval` match CDK's defaults but are set
|
|
83
|
+
* explicitly so the values are surfaced in the package's defaults table and
|
|
84
|
+
* can be reasoned about without consulting CDK source. `measureLatency` is
|
|
85
|
+
* defaulted ON to align with the AWS Well-Architected operational-excellence
|
|
86
|
+
* pillar (per-region latency visibility on the Route 53 Health Checks
|
|
87
|
+
* console). It carries a small additional cost — disable explicitly via
|
|
88
|
+
* `.measureLatency(false)` if cost is a concern.
|
|
89
|
+
*
|
|
90
|
+
* @see https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/dns-failover-determining-health-of-endpoints.html
|
|
91
|
+
*/
|
|
92
|
+
export declare const HEALTH_CHECK_DEFAULTS: Partial<HealthCheckBuilderProps>;
|
|
78
93
|
//# sourceMappingURL=defaults.d.ts.map
|
package/dist/defaults.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACv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;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,oBAAoB,CAE5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,oBAAoB,CAE5D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,OAAO,CAAC,uBAAuB,CAElE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,OAAO,CAAC,sBAAsB,CAEhE,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,EAAE,OAAO,CAAC,uBAAuB,CAIlE,CAAC"}
|
package/dist/defaults.js
CHANGED
|
@@ -102,4 +102,22 @@ export const HTTPS_RECORD_DEFAULTS = {
|
|
|
102
102
|
export const SVCB_RECORD_DEFAULTS = {
|
|
103
103
|
ttl: DEFAULT_RECORD_TTL,
|
|
104
104
|
};
|
|
105
|
+
/**
|
|
106
|
+
* Defaults for {@link createHealthCheckBuilder}. Overridable via the fluent API.
|
|
107
|
+
*
|
|
108
|
+
* `failureThreshold` and `requestInterval` match CDK's defaults but are set
|
|
109
|
+
* explicitly so the values are surfaced in the package's defaults table and
|
|
110
|
+
* can be reasoned about without consulting CDK source. `measureLatency` is
|
|
111
|
+
* defaulted ON to align with the AWS Well-Architected operational-excellence
|
|
112
|
+
* pillar (per-region latency visibility on the Route 53 Health Checks
|
|
113
|
+
* console). It carries a small additional cost — disable explicitly via
|
|
114
|
+
* `.measureLatency(false)` if cost is a concern.
|
|
115
|
+
*
|
|
116
|
+
* @see https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/dns-failover-determining-health-of-endpoints.html
|
|
117
|
+
*/
|
|
118
|
+
export const HEALTH_CHECK_DEFAULTS = {
|
|
119
|
+
failureThreshold: 3,
|
|
120
|
+
requestInterval: Duration.seconds(30),
|
|
121
|
+
measureLatency: true,
|
|
122
|
+
};
|
|
105
123
|
//# sourceMappingURL=defaults.js.map
|
package/dist/defaults.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAevC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAoC;IACnE;;;OAGG;IACH,cAAc,EAAE,IAAI;CACrB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,kBAAkB,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAE/C;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAiC;IAC7D,GAAG,EAAE,kBAAkB;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAoC;IACnE,GAAG,EAAE,kBAAkB;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAqC;IACrE,GAAG,EAAE,kBAAkB;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAmC;IACjE,GAAG,EAAE,kBAAkB;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAkC;IAC/D,GAAG,EAAE,kBAAkB;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAmC;IACjE,GAAG,EAAE,kBAAkB;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAmC;IACjE,GAAG,EAAE,kBAAkB;CACxB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAkC;IAC/D,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAkC;IAC/D,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAqC;IACrE,GAAG,EAAE,kBAAkB;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAoC;IACnE,GAAG,EAAE,kBAAkB;CACxB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAqC;IACrE,gBAAgB,EAAE,CAAC;IACnB,eAAe,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;IACrC,cAAc,EAAE,IAAI;CACrB,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { type IHealthCheck } from "aws-cdk-lib/aws-route53";
|
|
2
|
+
import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
3
|
+
import { type IConstruct } from "constructs";
|
|
4
|
+
import { type IBuilder, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
5
|
+
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
6
|
+
import type { HealthCheckAlarmConfig } from "./health-check-alarm-config.js";
|
|
7
|
+
import type { HealthCheckBuilderResult } from "./health-check-builder.js";
|
|
8
|
+
/**
|
|
9
|
+
* Configuration properties for {@link createHealthCheckAlarmBuilder}.
|
|
10
|
+
*
|
|
11
|
+
* The standalone alarm builder mirrors the alarm surface that
|
|
12
|
+
* {@link createHealthCheckBuilder} creates by default. It exists so that
|
|
13
|
+
* alarms can be created in a different stack from the health check itself —
|
|
14
|
+
* specifically a `us-east-1` stack, since Route 53 emits all health check
|
|
15
|
+
* metrics there regardless of the health check's stack region.
|
|
16
|
+
*
|
|
17
|
+
* @see ADR-0004 — Split-alarm builder pattern for fixed-region metrics
|
|
18
|
+
*/
|
|
19
|
+
export interface HealthCheckAlarmBuilderProps {
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for AWS-recommended CloudWatch alarms.
|
|
22
|
+
*
|
|
23
|
+
* Mirrors {@link HealthCheckBuilderProps.recommendedAlarms}. Set to
|
|
24
|
+
* `false` to disable all recommended alarms. Custom alarms added via
|
|
25
|
+
* {@link IHealthCheckAlarmBuilder.addAlarm} are unaffected.
|
|
26
|
+
*
|
|
27
|
+
* No alarm actions are configured by default. Use `alarmActionsPolicy`
|
|
28
|
+
* (or an `afterBuild` hook) to wire SNS or other actions onto the
|
|
29
|
+
* resulting alarms.
|
|
30
|
+
*
|
|
31
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Route53
|
|
32
|
+
*/
|
|
33
|
+
recommendedAlarms?: HealthCheckAlarmConfig | false;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The build output of an {@link IHealthCheckAlarmBuilder}.
|
|
37
|
+
*/
|
|
38
|
+
export interface HealthCheckAlarmBuilderResult {
|
|
39
|
+
/**
|
|
40
|
+
* The CloudWatch alarms created by this builder, keyed by alarm name.
|
|
41
|
+
* Uses the same key scheme as {@link HealthCheckBuilderResult.alarms}.
|
|
42
|
+
*/
|
|
43
|
+
alarms: Record<string, Alarm>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A fluent builder for Route 53 health-check CloudWatch alarms, decoupled
|
|
47
|
+
* from the health check itself. Use this when the health check lives in a
|
|
48
|
+
* stack outside `us-east-1` — route this component into a `us-east-1` stack
|
|
49
|
+
* via `compose().withStacks()` so the alarms land where Route 53 actually
|
|
50
|
+
* emits metrics.
|
|
51
|
+
*
|
|
52
|
+
* @see {@link createHealthCheckAlarmBuilder}
|
|
53
|
+
*/
|
|
54
|
+
export type IHealthCheckAlarmBuilder = IBuilder<HealthCheckAlarmBuilderProps, HealthCheckAlarmBuilder>;
|
|
55
|
+
/**
|
|
56
|
+
* Shared alarm-assembly used by both {@link createHealthCheckBuilder} (in its
|
|
57
|
+
* own stack) and {@link createHealthCheckAlarmBuilder} (typically in a
|
|
58
|
+
* separate `us-east-1` stack). Materialises the recommended health-check
|
|
59
|
+
* alarm and any user-supplied custom alarms, emits the region warning if the
|
|
60
|
+
* resulting scope is not in `us-east-1`, and creates the alarm constructs.
|
|
61
|
+
*
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
export declare function buildHealthCheckAlarms(scope: IConstruct, id: string, target: Pick<HealthCheckBuilderResult, "healthCheck">, options?: {
|
|
65
|
+
recommendedAlarms?: HealthCheckAlarmConfig | false;
|
|
66
|
+
customAlarms?: AlarmDefinitionBuilder<IHealthCheck>[];
|
|
67
|
+
}): Record<string, Alarm>;
|
|
68
|
+
declare class HealthCheckAlarmBuilder implements Lifecycle<HealthCheckAlarmBuilderResult> {
|
|
69
|
+
#private;
|
|
70
|
+
props: Partial<HealthCheckAlarmBuilderProps>;
|
|
71
|
+
/**
|
|
72
|
+
* Sets the health check to alarm on. Pass the result of
|
|
73
|
+
* {@link createHealthCheckBuilder} (or a {@link Ref} to it). The builder
|
|
74
|
+
* reads the health check from the result.
|
|
75
|
+
*
|
|
76
|
+
* Pair with `compose().withStacks()` to route this component into a
|
|
77
|
+
* `us-east-1` stack while the health check itself lives elsewhere — set
|
|
78
|
+
* `crossRegionReferences: true` on both stacks so CDK can wire the
|
|
79
|
+
* `HealthCheckId` reference automatically.
|
|
80
|
+
*/
|
|
81
|
+
healthCheck(healthCheck: Resolvable<HealthCheckBuilderResult>): this;
|
|
82
|
+
/**
|
|
83
|
+
* Adds a custom alarm against the health check. The configure callback
|
|
84
|
+
* receives a fresh {@link AlarmDefinitionBuilder} pre-set with the alarm's
|
|
85
|
+
* key; configure metric, threshold, comparison and any other options.
|
|
86
|
+
*
|
|
87
|
+
* The created alarm is materialised in this builder's stack — useful for
|
|
88
|
+
* cross-region setups where you want all health-check alarms to live with
|
|
89
|
+
* the recommended ones.
|
|
90
|
+
*/
|
|
91
|
+
addAlarm(key: string, configure: (alarm: AlarmDefinitionBuilder<IHealthCheck>) => AlarmDefinitionBuilder<IHealthCheck>): this;
|
|
92
|
+
build(scope: IConstruct, id: string, context?: Record<string, object>): HealthCheckAlarmBuilderResult;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Creates a new {@link IHealthCheckAlarmBuilder} for materialising Route 53
|
|
96
|
+
* health-check alarms in a stack separate from the health check itself.
|
|
97
|
+
*
|
|
98
|
+
* The recommended use is multi-region deployments: the health check lives in
|
|
99
|
+
* the application's stack (in any region — Route 53 health checks are
|
|
100
|
+
* global), and the alarms must live in a `us-east-1` stack so they can read
|
|
101
|
+
* the metrics Route 53 emits there.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* compose(
|
|
106
|
+
* {
|
|
107
|
+
* api: createHealthCheckBuilder()
|
|
108
|
+
* .type(HealthCheckType.HTTPS)
|
|
109
|
+
* .fqdn("api.example.com")
|
|
110
|
+
* .recommendedAlarms(false), // suppress alarms in the api's own stack
|
|
111
|
+
*
|
|
112
|
+
* apiAlarms: createHealthCheckAlarmBuilder()
|
|
113
|
+
* .healthCheck(ref<HealthCheckBuilderResult>("api"))
|
|
114
|
+
* .recommendedAlarms({ healthCheckStatus: { evaluationPeriods: 2 } }),
|
|
115
|
+
* },
|
|
116
|
+
* { api: [], apiAlarms: ["api"] },
|
|
117
|
+
* )
|
|
118
|
+
* .withStacks({
|
|
119
|
+
* api: appStack, // any region — health checks are global
|
|
120
|
+
* apiAlarms: monitoringStack, // us-east-1 — where AWS/Route53 metrics live
|
|
121
|
+
* })
|
|
122
|
+
* .build(app, "App");
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* Set `crossRegionReferences: true` on both stacks so CDK can export the
|
|
126
|
+
* `HealthCheckId` from the app stack and import it in the alarm stack.
|
|
127
|
+
*/
|
|
128
|
+
export declare function createHealthCheckAlarmBuilder(): IHealthCheckAlarmBuilder;
|
|
129
|
+
export {};
|
|
130
|
+
//# sourceMappingURL=health-check-alarm-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-check-alarm-builder.d.ts","sourceRoot":"","sources":["../src/health-check-alarm-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,SAAS,EAEd,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,sBAAsB,EAAgB,MAAM,0BAA0B,CAAC;AAChF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAE7E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAE1E;;;;;;;;;;GAUG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;;;;;;;;;;;OAYG;IACH,iBAAiB,CAAC,EAAE,sBAAsB,GAAG,KAAK,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAC7C,4BAA4B,EAC5B,uBAAuB,CACxB,CAAC;AAsBF;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,IAAI,CAAC,wBAAwB,EAAE,aAAa,CAAC,EACrD,OAAO,GAAE;IACP,iBAAiB,CAAC,EAAE,sBAAsB,GAAG,KAAK,CAAC;IACnD,YAAY,CAAC,EAAE,sBAAsB,CAAC,YAAY,CAAC,EAAE,CAAC;CAClD,GACL,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAevB;AAED,cAAM,uBAAwB,YAAW,SAAS,CAAC,6BAA6B,CAAC;;IAC/E,KAAK,EAAE,OAAO,CAAC,4BAA4B,CAAC,CAAM;IAIlD;;;;;;;;;OASG;IACH,WAAW,CAAC,WAAW,EAAE,UAAU,CAAC,wBAAwB,CAAC,GAAG,IAAI;IAKpE;;;;;;;;OAQG;IACH,QAAQ,CACN,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,CACT,KAAK,EAAE,sBAAsB,CAAC,YAAY,CAAC,KACxC,sBAAsB,CAAC,YAAY,CAAC,GACxC,IAAI;IAKP,KAAK,CACH,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,6BAA6B;CAejC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,6BAA6B,IAAI,wBAAwB,CAExE"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Annotations, Stack, Token } from "aws-cdk-lib";
|
|
2
|
+
import { Builder, resolve, } from "@composurecdk/core";
|
|
3
|
+
import { AlarmDefinitionBuilder, createAlarms } from "@composurecdk/cloudwatch";
|
|
4
|
+
import { resolveHealthCheckAlarmDefinitions } from "./health-check-alarms.js";
|
|
5
|
+
/**
|
|
6
|
+
* Route 53 health-check metrics are emitted in `us-east-1` only. CloudWatch
|
|
7
|
+
* alarms are regional, so alarms created in any other region will never
|
|
8
|
+
* receive data. Warn (don't error) when alarms are being created outside
|
|
9
|
+
* `us-east-1`, unless the region is an unresolved token (env-agnostic stack
|
|
10
|
+
* — user knows best).
|
|
11
|
+
*/
|
|
12
|
+
function warnIfNotUsEast1(scope) {
|
|
13
|
+
const region = Stack.of(scope).region;
|
|
14
|
+
if (Token.isUnresolved(region))
|
|
15
|
+
return;
|
|
16
|
+
if (region === "us-east-1")
|
|
17
|
+
return;
|
|
18
|
+
Annotations.of(scope).addWarningV2("@composurecdk/route53:alarm-region", `Route 53 health-check metrics are emitted in us-east-1 only, but this stack is ` +
|
|
19
|
+
`deployed in "${region}". CloudWatch alarms created here will not fire. Deploy the ` +
|
|
20
|
+
`stack in us-east-1, or use createHealthCheckAlarmBuilder() routed to a ` +
|
|
21
|
+
`us-east-1 stack via compose().withStacks().`);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Shared alarm-assembly used by both {@link createHealthCheckBuilder} (in its
|
|
25
|
+
* own stack) and {@link createHealthCheckAlarmBuilder} (typically in a
|
|
26
|
+
* separate `us-east-1` stack). Materialises the recommended health-check
|
|
27
|
+
* alarm and any user-supplied custom alarms, emits the region warning if the
|
|
28
|
+
* resulting scope is not in `us-east-1`, and creates the alarm constructs.
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export function buildHealthCheckAlarms(scope, id, target, options = {}) {
|
|
33
|
+
const recommended = options.recommendedAlarms;
|
|
34
|
+
const recommendedDefs = recommended === false || recommended?.enabled === false
|
|
35
|
+
? []
|
|
36
|
+
: resolveHealthCheckAlarmDefinitions(target.healthCheck, recommended);
|
|
37
|
+
const customAlarmDefs = options.customAlarms?.map((b) => b.resolve(target.healthCheck)) ?? [];
|
|
38
|
+
const allAlarmDefs = [...recommendedDefs, ...customAlarmDefs];
|
|
39
|
+
if (allAlarmDefs.length > 0) {
|
|
40
|
+
warnIfNotUsEast1(scope);
|
|
41
|
+
}
|
|
42
|
+
return createAlarms(scope, id, allAlarmDefs);
|
|
43
|
+
}
|
|
44
|
+
class HealthCheckAlarmBuilder {
|
|
45
|
+
props = {};
|
|
46
|
+
#healthCheck;
|
|
47
|
+
#customAlarms = [];
|
|
48
|
+
/**
|
|
49
|
+
* Sets the health check to alarm on. Pass the result of
|
|
50
|
+
* {@link createHealthCheckBuilder} (or a {@link Ref} to it). The builder
|
|
51
|
+
* reads the health check from the result.
|
|
52
|
+
*
|
|
53
|
+
* Pair with `compose().withStacks()` to route this component into a
|
|
54
|
+
* `us-east-1` stack while the health check itself lives elsewhere — set
|
|
55
|
+
* `crossRegionReferences: true` on both stacks so CDK can wire the
|
|
56
|
+
* `HealthCheckId` reference automatically.
|
|
57
|
+
*/
|
|
58
|
+
healthCheck(healthCheck) {
|
|
59
|
+
this.#healthCheck = healthCheck;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Adds a custom alarm against the health check. The configure callback
|
|
64
|
+
* receives a fresh {@link AlarmDefinitionBuilder} pre-set with the alarm's
|
|
65
|
+
* key; configure metric, threshold, comparison and any other options.
|
|
66
|
+
*
|
|
67
|
+
* The created alarm is materialised in this builder's stack — useful for
|
|
68
|
+
* cross-region setups where you want all health-check alarms to live with
|
|
69
|
+
* the recommended ones.
|
|
70
|
+
*/
|
|
71
|
+
addAlarm(key, configure) {
|
|
72
|
+
this.#customAlarms.push(configure(new AlarmDefinitionBuilder(key)));
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
build(scope, id, context) {
|
|
76
|
+
if (!this.#healthCheck) {
|
|
77
|
+
throw new Error(`HealthCheckAlarmBuilder "${id}" requires a health check. ` +
|
|
78
|
+
`Call .healthCheck() with a HealthCheckBuilderResult or a Ref to one.`);
|
|
79
|
+
}
|
|
80
|
+
const target = resolve(this.#healthCheck, context ?? {});
|
|
81
|
+
return {
|
|
82
|
+
alarms: buildHealthCheckAlarms(scope, id, target, {
|
|
83
|
+
recommendedAlarms: this.props.recommendedAlarms,
|
|
84
|
+
customAlarms: this.#customAlarms,
|
|
85
|
+
}),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Creates a new {@link IHealthCheckAlarmBuilder} for materialising Route 53
|
|
91
|
+
* health-check alarms in a stack separate from the health check itself.
|
|
92
|
+
*
|
|
93
|
+
* The recommended use is multi-region deployments: the health check lives in
|
|
94
|
+
* the application's stack (in any region — Route 53 health checks are
|
|
95
|
+
* global), and the alarms must live in a `us-east-1` stack so they can read
|
|
96
|
+
* the metrics Route 53 emits there.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* compose(
|
|
101
|
+
* {
|
|
102
|
+
* api: createHealthCheckBuilder()
|
|
103
|
+
* .type(HealthCheckType.HTTPS)
|
|
104
|
+
* .fqdn("api.example.com")
|
|
105
|
+
* .recommendedAlarms(false), // suppress alarms in the api's own stack
|
|
106
|
+
*
|
|
107
|
+
* apiAlarms: createHealthCheckAlarmBuilder()
|
|
108
|
+
* .healthCheck(ref<HealthCheckBuilderResult>("api"))
|
|
109
|
+
* .recommendedAlarms({ healthCheckStatus: { evaluationPeriods: 2 } }),
|
|
110
|
+
* },
|
|
111
|
+
* { api: [], apiAlarms: ["api"] },
|
|
112
|
+
* )
|
|
113
|
+
* .withStacks({
|
|
114
|
+
* api: appStack, // any region — health checks are global
|
|
115
|
+
* apiAlarms: monitoringStack, // us-east-1 — where AWS/Route53 metrics live
|
|
116
|
+
* })
|
|
117
|
+
* .build(app, "App");
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* Set `crossRegionReferences: true` on both stacks so CDK can export the
|
|
121
|
+
* `HealthCheckId` from the app stack and import it in the alarm stack.
|
|
122
|
+
*/
|
|
123
|
+
export function createHealthCheckAlarmBuilder() {
|
|
124
|
+
return Builder(HealthCheckAlarmBuilder);
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=health-check-alarm-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-check-alarm-builder.js","sourceRoot":"","sources":["../src/health-check-alarm-builder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,EACL,OAAO,EAGP,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are created for a Route 53 health check.
|
|
4
|
+
* The single recommended alarm — `healthCheckStatus` — is enabled by default
|
|
5
|
+
* with the AWS-recommended threshold. Set it to `false` to disable, or
|
|
6
|
+
* provide an {@link AlarmConfig} to tune the threshold or evaluation window.
|
|
7
|
+
*
|
|
8
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Route53
|
|
9
|
+
*/
|
|
10
|
+
export interface HealthCheckAlarmConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Master switch: set to `false` to disable all recommended alarms.
|
|
13
|
+
* Individual alarms can also be disabled via their own entry.
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Alarm when the health check is reporting unhealthy.
|
|
19
|
+
*
|
|
20
|
+
* Metric: `AWS/Route53 HealthCheckStatus`, statistic Minimum, period
|
|
21
|
+
* 1 minute, dimension `HealthCheckId`. Minimum is the AWS-recommended
|
|
22
|
+
* statistic — it surfaces "at least one Route 53 checker sees it down"
|
|
23
|
+
* during the period.
|
|
24
|
+
*
|
|
25
|
+
* Default threshold: `< 1` for one consecutive 1-minute period.
|
|
26
|
+
* Default `treatMissingData: breaching` — missing data is treated as
|
|
27
|
+
* unhealthy, matching the AWS example.
|
|
28
|
+
*
|
|
29
|
+
* Note: `AWS/Route53` metrics are emitted only in `us-east-1`. Alarms
|
|
30
|
+
* created against this metric in any other region will never receive
|
|
31
|
+
* data. The builder emits a synth-time warning when this happens; for
|
|
32
|
+
* stacks outside `us-east-1`, route the alarm into a `us-east-1` stack
|
|
33
|
+
* via `createHealthCheckAlarmBuilder()` and `compose().withStacks()`.
|
|
34
|
+
*
|
|
35
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Route53
|
|
36
|
+
*/
|
|
37
|
+
healthCheckStatus?: AlarmConfig | false;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=health-check-alarm-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-check-alarm-config.d.ts","sourceRoot":"","sources":["../src/health-check-alarm-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,iBAAiB,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;CACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-check-alarm-config.js","sourceRoot":"","sources":["../src/health-check-alarm-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AlarmConfigDefaults } from "@composurecdk/cloudwatch";
|
|
2
|
+
interface HealthCheckAlarmDefaults {
|
|
3
|
+
enabled: true;
|
|
4
|
+
healthCheckStatus: AlarmConfigDefaults;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* AWS-recommended default alarm configuration for Route 53 health checks.
|
|
8
|
+
*
|
|
9
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Route53
|
|
10
|
+
*/
|
|
11
|
+
export declare const HEALTH_CHECK_ALARM_DEFAULTS: HealthCheckAlarmDefaults;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=health-check-alarm-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-check-alarm-defaults.d.ts","sourceRoot":"","sources":["../src/health-check-alarm-defaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,UAAU,wBAAwB;IAChC,OAAO,EAAE,IAAI,CAAC;IACd,iBAAiB,EAAE,mBAAmB,CAAC;CACxC;AAED;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,EAAE,wBAmBzC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TreatMissingData } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
|
+
/**
|
|
3
|
+
* AWS-recommended default alarm configuration for Route 53 health checks.
|
|
4
|
+
*
|
|
5
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Route53
|
|
6
|
+
*/
|
|
7
|
+
export const HEALTH_CHECK_ALARM_DEFAULTS = {
|
|
8
|
+
enabled: true,
|
|
9
|
+
/**
|
|
10
|
+
* Alarm when `HealthCheckStatus < 1` for one consecutive 1-minute period.
|
|
11
|
+
* The metric is 0 (unhealthy) or 1 (healthy) per Route 53 checker, so the
|
|
12
|
+
* `Minimum` statistic surfaces "at least one checker reports unhealthy."
|
|
13
|
+
*
|
|
14
|
+
* `treatMissingData: breaching` matches AWS's recommendation — missing
|
|
15
|
+
* datapoints are treated as unhealthy. This guards against situations
|
|
16
|
+
* where the metric stops emitting (e.g. health check deletion) while the
|
|
17
|
+
* downstream system still depends on it.
|
|
18
|
+
*/
|
|
19
|
+
healthCheckStatus: {
|
|
20
|
+
threshold: 1,
|
|
21
|
+
evaluationPeriods: 1,
|
|
22
|
+
datapointsToAlarm: 1,
|
|
23
|
+
treatMissingData: TreatMissingData.BREACHING,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=health-check-alarm-defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-check-alarm-defaults.js","sourceRoot":"","sources":["../src/health-check-alarm-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAQ9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAA6B;IACnE,OAAO,EAAE,IAAI;IAEb;;;;;;;;;OASG;IACH,iBAAiB,EAAE;QACjB,SAAS,EAAE,CAAC;QACZ,iBAAiB,EAAE,CAAC;QACpB,iBAAiB,EAAE,CAAC;QACpB,gBAAgB,EAAE,gBAAgB,CAAC,SAAS;KAC7C;CACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IHealthCheck } from "aws-cdk-lib/aws-route53";
|
|
2
|
+
import type { AlarmDefinition } from "@composurecdk/cloudwatch";
|
|
3
|
+
import type { HealthCheckAlarmConfig } from "./health-check-alarm-config.js";
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the recommended alarm configuration into fully-resolved
|
|
6
|
+
* {@link AlarmDefinition}s for a Route 53 health check.
|
|
7
|
+
*
|
|
8
|
+
* Period and statistic are fixed at the AWS-recommended values
|
|
9
|
+
* (1 minute, Minimum) and not exposed as configuration knobs — they are
|
|
10
|
+
* load-bearing for the recommended semantics ("the worst checker reading
|
|
11
|
+
* per minute"). Threshold, evaluation periods, datapoints, and missing-data
|
|
12
|
+
* behaviour remain user-configurable via {@link HealthCheckAlarmConfig}.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveHealthCheckAlarmDefinitions(healthCheck: IHealthCheck, config: HealthCheckAlarmConfig | undefined): AlarmDefinition[];
|
|
15
|
+
//# sourceMappingURL=health-check-alarms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-check-alarms.d.ts","sourceRoot":"","sources":["../src/health-check-alarms.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAK7E;;;;;;;;;GASG;AACH,wBAAgB,kCAAkC,CAChD,WAAW,EAAE,YAAY,EACzB,MAAM,EAAE,sBAAsB,GAAG,SAAS,GACzC,eAAe,EAAE,CA8BnB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Duration } from "aws-cdk-lib";
|
|
2
|
+
import { ComparisonOperator, Metric, Stats } from "aws-cdk-lib/aws-cloudwatch";
|
|
3
|
+
import { resolveAlarmConfig } from "@composurecdk/cloudwatch";
|
|
4
|
+
import { HEALTH_CHECK_ALARM_DEFAULTS } from "./health-check-alarm-defaults.js";
|
|
5
|
+
const METRIC_PERIOD = Duration.minutes(1);
|
|
6
|
+
/**
|
|
7
|
+
* Resolves the recommended alarm configuration into fully-resolved
|
|
8
|
+
* {@link AlarmDefinition}s for a Route 53 health check.
|
|
9
|
+
*
|
|
10
|
+
* Period and statistic are fixed at the AWS-recommended values
|
|
11
|
+
* (1 minute, Minimum) and not exposed as configuration knobs — they are
|
|
12
|
+
* load-bearing for the recommended semantics ("the worst checker reading
|
|
13
|
+
* per minute"). Threshold, evaluation periods, datapoints, and missing-data
|
|
14
|
+
* behaviour remain user-configurable via {@link HealthCheckAlarmConfig}.
|
|
15
|
+
*/
|
|
16
|
+
export function resolveHealthCheckAlarmDefinitions(healthCheck, config) {
|
|
17
|
+
if (config?.enabled === false)
|
|
18
|
+
return [];
|
|
19
|
+
const definitions = [];
|
|
20
|
+
if (config?.healthCheckStatus !== false) {
|
|
21
|
+
const cfg = resolveAlarmConfig(config?.healthCheckStatus, HEALTH_CHECK_ALARM_DEFAULTS.healthCheckStatus);
|
|
22
|
+
definitions.push({
|
|
23
|
+
key: "healthCheckStatus",
|
|
24
|
+
alarmName: cfg.alarmName,
|
|
25
|
+
metric: new Metric({
|
|
26
|
+
namespace: "AWS/Route53",
|
|
27
|
+
metricName: "HealthCheckStatus",
|
|
28
|
+
dimensionsMap: { HealthCheckId: healthCheck.healthCheckId },
|
|
29
|
+
statistic: Stats.MINIMUM,
|
|
30
|
+
period: METRIC_PERIOD,
|
|
31
|
+
}),
|
|
32
|
+
threshold: cfg.threshold,
|
|
33
|
+
comparisonOperator: ComparisonOperator.LESS_THAN_THRESHOLD,
|
|
34
|
+
evaluationPeriods: cfg.evaluationPeriods,
|
|
35
|
+
datapointsToAlarm: cfg.datapointsToAlarm,
|
|
36
|
+
treatMissingData: cfg.treatMissingData,
|
|
37
|
+
description: `Route 53 health check is reporting unhealthy. Threshold: HealthCheckStatus < ${String(cfg.threshold)} (Minimum, 1 minute).`,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return definitions;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=health-check-alarms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-check-alarms.js","sourceRoot":"","sources":["../src/health-check-alarms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAG/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAE1C;;;;;;;;;GASG;AACH,MAAM,UAAU,kCAAkC,CAChD,WAAyB,EACzB,MAA0C;IAE1C,IAAI,MAAM,EAAE,OAAO,KAAK,KAAK;QAAE,OAAO,EAAE,CAAC;IAEzC,MAAM,WAAW,GAAsB,EAAE,CAAC;IAE1C,IAAI,MAAM,EAAE,iBAAiB,KAAK,KAAK,EAAE,CAAC;QACxC,MAAM,GAAG,GAAG,kBAAkB,CAC5B,MAAM,EAAE,iBAAiB,EACzB,2BAA2B,CAAC,iBAAiB,CAC9C,CAAC;QACF,WAAW,CAAC,IAAI,CAAC;YACf,GAAG,EAAE,mBAAmB;YACxB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,MAAM,EAAE,IAAI,MAAM,CAAC;gBACjB,SAAS,EAAE,aAAa;gBACxB,UAAU,EAAE,mBAAmB;gBAC/B,aAAa,EAAE,EAAE,aAAa,EAAE,WAAW,CAAC,aAAa,EAAE;gBAC3D,SAAS,EAAE,KAAK,CAAC,OAAO;gBACxB,MAAM,EAAE,aAAa;aACtB,CAAC;YACF,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,kBAAkB,EAAE,kBAAkB,CAAC,mBAAmB;YAC1D,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;YACxC,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;YACxC,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;YACtC,WAAW,EAAE,gFAAgF,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,uBAAuB;SAC1I,CAAC,CAAC;IACL,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { HealthCheck, type HealthCheckProps, type IHealthCheck } from "aws-cdk-lib/aws-route53";
|
|
2
|
+
import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
3
|
+
import { type IConstruct } from "constructs";
|
|
4
|
+
import { type IBuilder, type Lifecycle } from "@composurecdk/core";
|
|
5
|
+
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
6
|
+
import type { HealthCheckAlarmConfig } from "./health-check-alarm-config.js";
|
|
7
|
+
/**
|
|
8
|
+
* Configuration properties for the Route 53 health-check builder.
|
|
9
|
+
*
|
|
10
|
+
* Extends the CDK {@link HealthCheckProps} with builder-specific options for
|
|
11
|
+
* AWS-recommended CloudWatch alarms.
|
|
12
|
+
*/
|
|
13
|
+
export interface HealthCheckBuilderProps extends HealthCheckProps {
|
|
14
|
+
/**
|
|
15
|
+
* Configuration for AWS-recommended CloudWatch alarms.
|
|
16
|
+
*
|
|
17
|
+
* By default, the builder creates a recommended `healthCheckStatus`
|
|
18
|
+
* alarm matching AWS guidance (`HealthCheckStatus < 1` for one minute,
|
|
19
|
+
* `treatMissingData: breaching`). The alarm can be customised or
|
|
20
|
+
* disabled. Set to `false` to disable all alarms.
|
|
21
|
+
*
|
|
22
|
+
* No alarm actions are configured by default since notification methods
|
|
23
|
+
* are user-specific. Access alarms from the build result or use an
|
|
24
|
+
* `afterBuild` hook (or `alarmActionsPolicy`) to apply actions.
|
|
25
|
+
*
|
|
26
|
+
* Note: `AWS/Route53` metrics are emitted only in `us-east-1`. If this
|
|
27
|
+
* builder is used outside `us-east-1`, the synthesised alarm will never
|
|
28
|
+
* receive data — the builder emits a synth-time warning. For non-`us-east-1`
|
|
29
|
+
* stacks, suppress this builder's alarms with `recommendedAlarms: false`
|
|
30
|
+
* and create alarms in a `us-east-1` stack via
|
|
31
|
+
* {@link createHealthCheckAlarmBuilder}.
|
|
32
|
+
*
|
|
33
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Route53
|
|
34
|
+
*/
|
|
35
|
+
recommendedAlarms?: HealthCheckAlarmConfig | false;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The build output of an {@link IHealthCheckBuilder}.
|
|
39
|
+
*/
|
|
40
|
+
export interface HealthCheckBuilderResult {
|
|
41
|
+
/** The Route 53 health check construct created by the builder. */
|
|
42
|
+
healthCheck: HealthCheck;
|
|
43
|
+
/**
|
|
44
|
+
* CloudWatch alarms created for the health check, keyed by alarm name.
|
|
45
|
+
*
|
|
46
|
+
* Includes both AWS-recommended alarms and any custom alarms added via
|
|
47
|
+
* {@link IHealthCheckBuilder.addAlarm}. Access individual alarms by key
|
|
48
|
+
* (e.g. `result.alarms.healthCheckStatus`).
|
|
49
|
+
*
|
|
50
|
+
* No alarm actions are configured — apply them via the result or an
|
|
51
|
+
* `afterBuild` hook.
|
|
52
|
+
*
|
|
53
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Route53
|
|
54
|
+
*/
|
|
55
|
+
alarms: Record<string, Alarm>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A fluent builder for configuring and creating a Route 53 health check.
|
|
59
|
+
*
|
|
60
|
+
* Each configuration property from the CDK {@link HealthCheckProps} is
|
|
61
|
+
* exposed as an overloaded method: call with a value to set it (returns the
|
|
62
|
+
* builder for chaining), or call with no arguments to read the current value.
|
|
63
|
+
*
|
|
64
|
+
* The builder also creates the AWS-recommended `healthCheckStatus`
|
|
65
|
+
* CloudWatch alarm by default. Alarms can be customised or disabled via the
|
|
66
|
+
* `recommendedAlarms` property.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const hc = createHealthCheckBuilder()
|
|
71
|
+
* .type(HealthCheckType.HTTPS)
|
|
72
|
+
* .fqdn("api.example.com")
|
|
73
|
+
* .resourcePath("/health");
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export type IHealthCheckBuilder = IBuilder<HealthCheckBuilderProps, HealthCheckBuilder>;
|
|
77
|
+
declare class HealthCheckBuilder implements Lifecycle<HealthCheckBuilderResult> {
|
|
78
|
+
#private;
|
|
79
|
+
props: Partial<HealthCheckBuilderProps>;
|
|
80
|
+
addAlarm(key: string, configure: (alarm: AlarmDefinitionBuilder<IHealthCheck>) => AlarmDefinitionBuilder<IHealthCheck>): this;
|
|
81
|
+
build(scope: IConstruct, id: string): HealthCheckBuilderResult;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates a new {@link IHealthCheckBuilder} for configuring a Route 53
|
|
85
|
+
* health check.
|
|
86
|
+
*
|
|
87
|
+
* @returns A fluent builder for a Route 53 health check.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* const hc = createHealthCheckBuilder()
|
|
92
|
+
* .type(HealthCheckType.HTTPS)
|
|
93
|
+
* .fqdn("api.example.com");
|
|
94
|
+
*
|
|
95
|
+
* const result = hc.build(stack, "ApiHealthCheck");
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function createHealthCheckBuilder(): IHealthCheckBuilder;
|
|
99
|
+
export {};
|
|
100
|
+
//# sourceMappingURL=health-check-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-check-builder.d.ts","sourceRoot":"","sources":["../src/health-check-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAChG,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAW,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAI7E;;;;;GAKG;AACH,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;IAC/D;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,iBAAiB,CAAC,EAAE,sBAAsB,GAAG,KAAK,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,kEAAkE;IAClE,WAAW,EAAE,WAAW,CAAC;IAEzB;;;;;;;;;;;OAWG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,uBAAuB,EAAE,kBAAkB,CAAC,CAAC;AAExF,cAAM,kBAAmB,YAAW,SAAS,CAAC,wBAAwB,CAAC;;IACrE,KAAK,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAM;IAG7C,QAAQ,CACN,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,CACT,KAAK,EAAE,sBAAsB,CAAC,YAAY,CAAC,KACxC,sBAAsB,CAAC,YAAY,CAAC,GACxC,IAAI;IAKP,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,wBAAwB;CA4B/D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,IAAI,mBAAmB,CAE9D"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { HealthCheck } from "aws-cdk-lib/aws-route53";
|
|
2
|
+
import { Builder } from "@composurecdk/core";
|
|
3
|
+
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
4
|
+
import { buildHealthCheckAlarms } from "./health-check-alarm-builder.js";
|
|
5
|
+
import { HEALTH_CHECK_DEFAULTS } from "./defaults.js";
|
|
6
|
+
class HealthCheckBuilder {
|
|
7
|
+
props = {};
|
|
8
|
+
#customAlarms = [];
|
|
9
|
+
addAlarm(key, configure) {
|
|
10
|
+
this.#customAlarms.push(configure(new AlarmDefinitionBuilder(key)));
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
build(scope, id) {
|
|
14
|
+
const { recommendedAlarms, ...rest } = this.props;
|
|
15
|
+
if (!rest.type) {
|
|
16
|
+
throw new Error(`HealthCheckBuilder "${id}" requires a type. Call .type() with a HealthCheckType value.`);
|
|
17
|
+
}
|
|
18
|
+
const mergedProps = {
|
|
19
|
+
...HEALTH_CHECK_DEFAULTS,
|
|
20
|
+
...rest,
|
|
21
|
+
};
|
|
22
|
+
const healthCheck = new HealthCheck(scope, id, mergedProps);
|
|
23
|
+
const alarms = buildHealthCheckAlarms(scope, id, { healthCheck }, {
|
|
24
|
+
recommendedAlarms,
|
|
25
|
+
customAlarms: this.#customAlarms,
|
|
26
|
+
});
|
|
27
|
+
return { healthCheck, alarms };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new {@link IHealthCheckBuilder} for configuring a Route 53
|
|
32
|
+
* health check.
|
|
33
|
+
*
|
|
34
|
+
* @returns A fluent builder for a Route 53 health check.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const hc = createHealthCheckBuilder()
|
|
39
|
+
* .type(HealthCheckType.HTTPS)
|
|
40
|
+
* .fqdn("api.example.com");
|
|
41
|
+
*
|
|
42
|
+
* const result = hc.build(stack, "ApiHealthCheck");
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export function createHealthCheckBuilder() {
|
|
46
|
+
return Builder(HealthCheckBuilder);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=health-check-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-check-builder.js","sourceRoot":"","sources":["../src/health-check-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA4C,MAAM,yBAAyB,CAAC;AAGhG,OAAO,EAAE,OAAO,EAAiC,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AA4EtD,MAAM,kBAAkB;IACtB,KAAK,GAAqC,EAAE,CAAC;IACpC,aAAa,GAA2C,EAAE,CAAC;IAEpE,QAAQ,CACN,GAAW,EACX,SAEyC;QAEzC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,sBAAsB,CAAe,GAAG,CAAC,CAAC,CAAC,CAAC;QAClF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,KAAiB,EAAE,EAAU;QACjC,MAAM,EAAE,iBAAiB,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAElD,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACb,uBAAuB,EAAE,+DAA+D,CACzF,CAAC;QACJ,CAAC;QAED,MAAM,WAAW,GAAG;YAClB,GAAG,qBAAqB;YACxB,GAAG,IAAI;SACY,CAAC;QAEtB,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,KAAK,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;QAE5D,MAAM,MAAM,GAAG,sBAAsB,CACnC,KAAK,EACL,EAAE,EACF,EAAE,WAAW,EAAE,EACf;YACE,iBAAiB;YACjB,YAAY,EAAE,IAAI,CAAC,aAAa;SACjC,CACF,CAAC;QAEF,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;IACjC,CAAC;CACF;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO,OAAO,CAA8C,kBAAkB,CAAC,CAAC;AAClF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ export { createNsRecordBuilder, type NsRecordBuilderProps, type NsRecordBuilderR
|
|
|
10
10
|
export { createDsRecordBuilder, type DsRecordBuilderProps, type DsRecordBuilderResult, type IDsRecordBuilder, } from "./ds-record-builder.js";
|
|
11
11
|
export { createHttpsRecordBuilder, type HttpsRecordBuilderProps, type HttpsRecordBuilderResult, type IHttpsRecordBuilder, } from "./https-record-builder.js";
|
|
12
12
|
export { createSvcbRecordBuilder, type SvcbRecordBuilderProps, type SvcbRecordBuilderResult, type ISvcbRecordBuilder, } from "./svcb-record-builder.js";
|
|
13
|
+
export { createHealthCheckBuilder, type HealthCheckBuilderProps, type HealthCheckBuilderResult, type IHealthCheckBuilder, } from "./health-check-builder.js";
|
|
14
|
+
export { createHealthCheckAlarmBuilder, type HealthCheckAlarmBuilderProps, type HealthCheckAlarmBuilderResult, type IHealthCheckAlarmBuilder, } from "./health-check-alarm-builder.js";
|
|
15
|
+
export type { HealthCheckAlarmConfig } from "./health-check-alarm-config.js";
|
|
16
|
+
export { HEALTH_CHECK_ALARM_DEFAULTS } from "./health-check-alarm-defaults.js";
|
|
13
17
|
export { cloudfrontAliasTarget, apiGatewayAliasTarget, apiGatewayDomainAliasTarget, } from "./alias-targets.js";
|
|
14
|
-
export { HOSTED_ZONE_DEFAULTS, A_RECORD_DEFAULTS, AAAA_RECORD_DEFAULTS, CNAME_RECORD_DEFAULTS, TXT_RECORD_DEFAULTS, MX_RECORD_DEFAULTS, SRV_RECORD_DEFAULTS, CAA_RECORD_DEFAULTS, NS_RECORD_DEFAULTS, DS_RECORD_DEFAULTS, HTTPS_RECORD_DEFAULTS, SVCB_RECORD_DEFAULTS, } from "./defaults.js";
|
|
18
|
+
export { HOSTED_ZONE_DEFAULTS, A_RECORD_DEFAULTS, AAAA_RECORD_DEFAULTS, CNAME_RECORD_DEFAULTS, TXT_RECORD_DEFAULTS, MX_RECORD_DEFAULTS, SRV_RECORD_DEFAULTS, CAA_RECORD_DEFAULTS, NS_RECORD_DEFAULTS, DS_RECORD_DEFAULTS, HTTPS_RECORD_DEFAULTS, SVCB_RECORD_DEFAULTS, HEALTH_CHECK_DEFAULTS, } from "./defaults.js";
|
|
15
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,eAAe,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,uBAAuB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAC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C1B,KAAK,gBAAgB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,wBAAwB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,GACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,uBAAuB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,GACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,6BAA6B,EAC7B,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,KAAK,wBAAwB,GAC9B,MAAM,iCAAiC,CAAC;AACzC,YAAY,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,9 @@ export { createNsRecordBuilder, } from "./ns-record-builder.js";
|
|
|
10
10
|
export { createDsRecordBuilder, } from "./ds-record-builder.js";
|
|
11
11
|
export { createHttpsRecordBuilder, } from "./https-record-builder.js";
|
|
12
12
|
export { createSvcbRecordBuilder, } from "./svcb-record-builder.js";
|
|
13
|
+
export { createHealthCheckBuilder, } from "./health-check-builder.js";
|
|
14
|
+
export { createHealthCheckAlarmBuilder, } from "./health-check-alarm-builder.js";
|
|
15
|
+
export { HEALTH_CHECK_ALARM_DEFAULTS } from "./health-check-alarm-defaults.js";
|
|
13
16
|
export { cloudfrontAliasTarget, apiGatewayAliasTarget, apiGatewayDomainAliasTarget, } from "./alias-targets.js";
|
|
14
|
-
export { HOSTED_ZONE_DEFAULTS, A_RECORD_DEFAULTS, AAAA_RECORD_DEFAULTS, CNAME_RECORD_DEFAULTS, TXT_RECORD_DEFAULTS, MX_RECORD_DEFAULTS, SRV_RECORD_DEFAULTS, CAA_RECORD_DEFAULTS, NS_RECORD_DEFAULTS, DS_RECORD_DEFAULTS, HTTPS_RECORD_DEFAULTS, SVCB_RECORD_DEFAULTS, } from "./defaults.js";
|
|
17
|
+
export { HOSTED_ZONE_DEFAULTS, A_RECORD_DEFAULTS, AAAA_RECORD_DEFAULTS, CNAME_RECORD_DEFAULTS, TXT_RECORD_DEFAULTS, MX_RECORD_DEFAULTS, SRV_RECORD_DEFAULTS, CAA_RECORD_DEFAULTS, NS_RECORD_DEFAULTS, DS_RECORD_DEFAULTS, HTTPS_RECORD_DEFAULTS, SVCB_RECORD_DEFAULTS, HEALTH_CHECK_DEFAULTS, } from "./defaults.js";
|
|
15
18
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GAIxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,oBAAoB,GAIrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,uBAAuB,GAIxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,GAIzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,sBAAsB,GAIvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,qBAAqB,GAItB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,sBAAsB,GAIvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,sBAAsB,GAIvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,qBAAqB,GAItB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,qBAAqB,GAItB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,wBAAwB,GAIzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,uBAAuB,GAIxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GAIxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,oBAAoB,GAIrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,uBAAuB,GAIxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,GAIzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,sBAAsB,GAIvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,qBAAqB,GAItB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,sBAAsB,GAIvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,sBAAsB,GAIvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,qBAAqB,GAItB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,qBAAqB,GAItB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,wBAAwB,GAIzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,uBAAuB,GAIxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,GAIzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,6BAA6B,GAI9B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composurecdk/route53",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "Composable Route53 hosted zone and record builders with well-architected defaults",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"type": "module",
|
|
41
41
|
"peerDependencies": {
|
|
42
|
+
"@composurecdk/cloudwatch": "^0.4.0",
|
|
42
43
|
"@composurecdk/core": "^0.4.0",
|
|
43
44
|
"aws-cdk-lib": "^2.0.0",
|
|
44
45
|
"constructs": "^10.0.0"
|