Skip to content

Commit dc1edac

Browse files
author
Eugene Cheung
authored
fix(MonitoringAspect): allow specifying CloudFrontDistribution and WafV2 alarms (#609)
Fixes #607 Also replaces some things marked as deprecated in the unit tests just to make it less noisy. --- _By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license_
1 parent a397b93 commit dc1edac

File tree

5 files changed

+296
-27
lines changed

5 files changed

+296
-27
lines changed

API.md

Lines changed: 66 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/monitoring/aws-cloudfront/CloudFrontDistributionMonitoring.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ import {
3535
} from "../../dashboard";
3636

3737
export interface CloudFrontDistributionMonitoringOptions
38-
extends BaseMonitoringProps {}
39-
40-
export interface CloudFrontDistributionMonitoringProps
41-
extends CloudFrontDistributionMetricFactoryProps,
42-
CloudFrontDistributionMonitoringOptions {
38+
extends BaseMonitoringProps {
4339
readonly addError4xxRate?: Record<string, ErrorRateThreshold>;
4440
readonly addFault5xxRate?: Record<string, ErrorRateThreshold>;
4541

4642
readonly addLowTpsAlarm?: Record<string, LowTpsThreshold>;
4743
readonly addHighTpsAlarm?: Record<string, HighTpsThreshold>;
4844
}
4945

46+
export interface CloudFrontDistributionMonitoringProps
47+
extends CloudFrontDistributionMetricFactoryProps,
48+
CloudFrontDistributionMonitoringOptions {}
49+
5050
export class CloudFrontDistributionMonitoring extends Monitoring {
5151
readonly title: string;
5252
readonly distributionUrl?: string;

lib/monitoring/aws-wafv2/WafV2Monitoring.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ import {
2828
MonitoringNamingStrategy,
2929
} from "../../dashboard";
3030

31-
export interface WafV2MonitoringOptions extends BaseMonitoringProps {}
32-
33-
export interface WafV2MonitoringProps
34-
extends WafV2MetricFactoryProps,
35-
WafV2MonitoringOptions {
31+
export interface WafV2MonitoringOptions extends BaseMonitoringProps {
3632
readonly addBlockedRequestsCountAlarm?: Record<string, ErrorCountThreshold>;
3733
readonly addBlockedRequestsRateAlarm?: Record<string, ErrorRateThreshold>;
3834
}
3935

36+
export interface WafV2MonitoringProps
37+
extends WafV2MetricFactoryProps,
38+
WafV2MonitoringOptions {}
39+
4040
/**
4141
* Monitoring for AWS Web Application Firewall.
4242
*

test/facade/MonitoringAspect.test.ts

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,18 @@ describe("MonitoringAspect", () => {
196196
});
197197

198198
// WHEN
199-
facade.monitorScope(stack, defaultAspectProps);
199+
facade.monitorScope(stack, {
200+
...defaultAspectProps,
201+
cloudFront: {
202+
props: {
203+
addError4xxRate: {
204+
Warning: {
205+
maxErrorRate: 0.1,
206+
},
207+
},
208+
},
209+
},
210+
});
200211

201212
// THEN
202213
expect(Template.fromStack(stack)).toMatchSnapshot();
@@ -402,7 +413,7 @@ describe("MonitoringAspect", () => {
402413
new lambda.Function(stack, "DummyFunction", {
403414
code: lambda.Code.fromInline("lambda"),
404415
handler: "index.handler",
405-
runtime: lambda.Runtime.NODEJS_18_X,
416+
runtime: lambda.Runtime.NODEJS_LATEST,
406417
});
407418

408419
// WHEN
@@ -419,7 +430,7 @@ describe("MonitoringAspect", () => {
419430

420431
new opensearch.Domain(stack, "DummyOSDomain", {
421432
domainName: "dummy-os-domain",
422-
version: opensearch.EngineVersion.ELASTICSEARCH_7_10,
433+
version: opensearch.EngineVersion.OPENSEARCH_2_15,
423434
});
424435
new elasticsearch.Domain(stack, "DummyESDomain", {
425436
version: elasticsearch.ElasticsearchVersion.V7_10,
@@ -558,11 +569,22 @@ describe("MonitoringAspect", () => {
558569
code: synthetics.Code.fromInline("/* nothing */"),
559570
handler: "index.handler",
560571
}),
561-
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_5_1,
572+
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_9_0,
562573
});
563574

564575
// WHEN
565-
facade.monitorScope(stack, defaultAspectProps);
576+
facade.monitorScope(stack, {
577+
...defaultAspectProps,
578+
syntheticsCanaries: {
579+
props: {
580+
add4xxErrorCountAlarm: {
581+
Warning: {
582+
maxErrorCount: 0,
583+
},
584+
},
585+
},
586+
},
587+
});
566588

567589
// THEN
568590
expect(Template.fromStack(stack)).toMatchSnapshot();
@@ -584,7 +606,18 @@ describe("MonitoringAspect", () => {
584606
});
585607

586608
// WHEN
587-
facade.monitorScope(stack, defaultAspectProps);
609+
facade.monitorScope(stack, {
610+
...defaultAspectProps,
611+
webApplicationFirewallAclV2: {
612+
props: {
613+
addBlockedRequestsCountAlarm: {
614+
Warning: {
615+
maxErrorCount: 0,
616+
},
617+
},
618+
},
619+
},
620+
});
588621

589622
// THEN
590623
expect(Template.fromStack(stack)).toMatchSnapshot();

0 commit comments

Comments
 (0)