Skip to content

Commit

Permalink
Merge pull request #154 from capralifecycle/add-more-alarms
Browse files Browse the repository at this point in the history
Add more alarms
  • Loading branch information
stekern authored Oct 21, 2022
2 parents f73b750 + 7debf31 commit 04985c1
Show file tree
Hide file tree
Showing 8 changed files with 777 additions and 37 deletions.
126 changes: 126 additions & 0 deletions src/alarms/__tests__/__snapshots__/database-alarms.test.ts.snap

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

112 changes: 101 additions & 11 deletions src/alarms/__tests__/__snapshots__/service-alarms.test.ts.snap

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

35 changes: 35 additions & 0 deletions src/alarms/__tests__/database-alarms.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import "@aws-cdk/assert/jest"
import { App, Stack, Size } from "aws-cdk-lib"
import * as cloudwatchActions from "aws-cdk-lib/aws-cloudwatch-actions"
import * as sns from "aws-cdk-lib/aws-sns"
import * as ec2 from "aws-cdk-lib/aws-ec2"
import "jest-cdk-snapshot"
import { DatabaseAlarms } from "../database-alarms"

test("create alarms", () => {
const app = new App()
const supportStack = new Stack(app, "SupportStack")
const stack = new Stack(app, "Stack")

const topic = new sns.Topic(supportStack, "Topic")
const action = new cloudwatchActions.SnsAction(topic)

const alarms = new DatabaseAlarms(stack, "DatabaseAlarms", {
instanceIdentifier: "database-name",
instanceType: ec2.InstanceType.of(
ec2.InstanceClass.BURSTABLE3,
ec2.InstanceSize.MICRO,
),
allocatedStorage: Size.gibibytes(25),
action,
})

alarms.addCpuCreditsAlarm()
alarms.addCpuUtilizationAlarm({
threshold: 75,
})

alarms.addStorageSpaceAlarms()

expect(stack).toMatchCdkSnapshot()
})
4 changes: 2 additions & 2 deletions src/alarms/__tests__/service-alarms.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import "@aws-cdk/assert/jest"
import { App, Stack } from "aws-cdk-lib"
import * as cloudwatchActions from "aws-cdk-lib/aws-cloudwatch-actions"
import * as logs from "aws-cdk-lib/aws-logs"
import * as sns from "aws-cdk-lib/aws-sns"
import { App, Stack } from "aws-cdk-lib"
import "jest-cdk-snapshot"
import { ServiceAlarms } from "../service-alarms"

Expand All @@ -25,7 +25,7 @@ test("create alarms", () => {
logGroup,
})

alarms.addTargetGroupAlarm({
alarms.addTargetGroupAlarms({
loadBalancerFullName: "app/my-load-balancer/50dc6c495c0c9188",
targetGroupFullName: "targetgroup/my-target-group/cbf133c568e0d028",
})
Expand Down
Loading

0 comments on commit 04985c1

Please sign in to comment.