Skip to content

Commit

Permalink
feat!: require aws-cdk-lib ^2.160.0
Browse files Browse the repository at this point in the history
This unfortunately drops the guard for non-serverless DatabaseClusters for Aurora monitoring since
the constructs are now nearly indistinguishable based on their properties.
  • Loading branch information
echeung-amzn committed Nov 13, 2024
1 parent 4926bd0 commit 6cdb65a
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 580 deletions.
4 changes: 2 additions & 2 deletions .projen/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "projen";
import { TrailingComma } from "projen/lib/javascript";

const CDK_VERSION = "2.112.0";
const CDK_VERSION = "2.160.0";

const project = new awscdk.AwsCdkConstructLibrary({
name: "cdk-monitoring-constructs",
Expand All @@ -18,7 +18,7 @@ const project = new awscdk.AwsCdkConstructLibrary({
keywords: ["cloudwatch", "monitoring"],

defaultReleaseBranch: "main",
majorVersion: 8,
majorVersion: 9,
stability: "experimental",

cdkVersion: CDK_VERSION,
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ In your `package.json`:
```json
{
"dependencies": {
"cdk-monitoring-constructs": "^7.0.0",
"cdk-monitoring-constructs": "^9.0.0",

// peer dependencies of cdk-monitoring-constructs
"aws-cdk-lib": "^2.112.0",
"aws-cdk-lib": "^2.160.0",
"constructs": "^10.0.5"

// ...your other dependencies...
Expand Down
11 changes: 0 additions & 11 deletions lib/monitoring/aws-rds/AuroraClusterMonitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
HorizontalAnnotation,
IWidget,
} from "aws-cdk-lib/aws-cloudwatch";
import { ServerlessCluster } from "aws-cdk-lib/aws-rds";

import {
RdsClusterMetricFactory,
Expand Down Expand Up @@ -75,12 +74,6 @@ export class AuroraClusterMonitoring extends Monitoring {
constructor(scope: MonitoringScope, props: AuroraClusterMonitoringProps) {
super(scope, props);

if (!this.isServerlessCluster(props.cluster)) {
throw Error(
"Cluster is not of type `ServerlessCluster`. Monitoring is not applicable.",
);
}

const metricFactory = new RdsClusterMetricFactory(
scope.createMetricFactory(),
props,
Expand Down Expand Up @@ -164,10 +157,6 @@ export class AuroraClusterMonitoring extends Monitoring {
props.useCreatedAlarms?.consume(this.createdAlarms());
}

private isServerlessCluster(obj: any): obj is ServerlessCluster {
return (obj as any).clusterArn !== undefined;
}

summaryWidgets(): IWidget[] {
return [
this.createTitleWidget(),
Expand Down
6 changes: 3 additions & 3 deletions package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion test/dashboard/widget/__snapshots__/BitmapWidget.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

132 changes: 13 additions & 119 deletions test/facade/__snapshots__/MonitoringAspect.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 1 addition & 59 deletions test/monitoring/aws-rds/AuroraClusterMonitoring.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { Stack } from "aws-cdk-lib";
import { Template } from "aws-cdk-lib/assertions";
import { InstanceType, SubnetType, Vpc } from "aws-cdk-lib/aws-ec2";
import {
AuroraMysqlEngineVersion,
DatabaseCluster,
DatabaseClusterEngine,
ServerlessCluster,
} from "aws-cdk-lib/aws-rds";
import { DatabaseClusterEngine, ServerlessCluster } from "aws-cdk-lib/aws-rds";

import { AuroraClusterMonitoring } from "../../../lib";
import { addMonitoringDashboardsToStack } from "../../utils/SnapshotUtil";
Expand All @@ -31,58 +25,6 @@ test("snapshot test: no alarms", () => {
expect(Template.fromStack(stack)).toMatchSnapshot();
});

test("RDS passed into Aurora Cluster", () => {
const testGuard = () => {
const stack = new Stack();
const scope = new TestMonitoringScope(stack, "Scope");
const vpc = new Vpc(scope, "DummyVpc", {
maxAzs: 3,
});
const rdsCluster = new DatabaseCluster(scope, "DummyRdsCluster", {
engine: DatabaseClusterEngine.auroraMysql({
version: AuroraMysqlEngineVersion.VER_2_07_10,
}),
instanceProps: {
instanceType: new InstanceType("t3.small"),
vpcSubnets: {
subnetType: SubnetType.PUBLIC,
},
vpc,
},
});

new AuroraClusterMonitoring(scope, {
alarmFriendlyName: "DummyAuroraCluster",
cluster: rdsCluster,
addCpuUsageAlarm: {
Warning: {
maxUsagePercent: 80,
},
},
addMaxConnectionCountAlarm: {
Warning: {
maxConnectionCount: 100,
},
},
addMinConnectionCountAlarm: {
Warning: {
minConnectionCount: 0,
},
},
addMaxServerlessDatabaseCapacityAlarm: {
Warning: {
maxUsageCount: 100,
},
},
});
};

expect(testGuard).toThrow(Error);
expect(testGuard).toThrow(
"Cluster is not of type `ServerlessCluster`. Monitoring is not applicable.",
);
});

test("snapshot test: all alarms", () => {
const stack = new Stack();

Expand Down
Loading

0 comments on commit 6cdb65a

Please sign in to comment.