From 80240db60749ffc07b55b88c1b6af245f81de6d2 Mon Sep 17 00:00:00 2001 From: Niall Maher Date: Mon, 15 Jan 2024 20:07:54 +0000 Subject: [PATCH] Revert "Add CloudWatch notifications and SNS subscriptions" (#696) --- cdk/lib/app-stack.ts | 27 --------------------------- cdk/test/cdk-pipeline-codu.test.ts | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 27 deletions(-) create mode 100644 cdk/test/cdk-pipeline-codu.test.ts diff --git a/cdk/lib/app-stack.ts b/cdk/lib/app-stack.ts index 1817c9d7..3fb73c70 100644 --- a/cdk/lib/app-stack.ts +++ b/cdk/lib/app-stack.ts @@ -6,12 +6,9 @@ import type { Construct } from "constructs"; import * as ecs from "aws-cdk-lib/aws-ecs"; import * as ecsPatterns from "aws-cdk-lib/aws-ecs-patterns"; import * as ecrAssets from "aws-cdk-lib/aws-ecr-assets"; -import * as cloudwatch from "aws-cdk-lib/aws-cloudwatch"; import * as logs from "aws-cdk-lib/aws-logs"; import * as ssm from "aws-cdk-lib/aws-ssm"; -import * as sns from "aws-cdk-lib/aws-sns"; import * as iam from "aws-cdk-lib/aws-iam"; -import * as snsSubscriptions from "aws-cdk-lib/aws-sns-subscriptions"; interface Props extends cdk.StackProps { bucket: cdk.aws_s3.Bucket; @@ -205,29 +202,5 @@ export class AppStack extends cdk.Stack { ); this.loadbalancer = fargateService.loadBalancer; - - // Cloudwatch notifications - const alarm = new cloudwatch.Alarm(this, "FargateServiceDownAlarm", { - alarmName: "FargateServiceDownAlarm", - alarmDescription: "Triggered when Fargate service is down", - metric: fargateService.service.metricCpuUtilization(), - threshold: 10, - evaluationPeriods: 1, - comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_THRESHOLD, - treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING, - }); - - const snsTopic = new sns.Topic(this, "FargateServiceAlertTopic"); - alarm.addAlarmAction(new cdk.aws_cloudwatch_actions.SnsAction(snsTopic)); - - snsTopic.addSubscription( - new snsSubscriptions.EmailSubscription( - ssm.StringParameter.fromStringParameterName( - this, - "alertEmail", - "/env/alertEmail", - ).toString(), - ), - ); } } diff --git a/cdk/test/cdk-pipeline-codu.test.ts b/cdk/test/cdk-pipeline-codu.test.ts new file mode 100644 index 00000000..8e74cdd0 --- /dev/null +++ b/cdk/test/cdk-pipeline-codu.test.ts @@ -0,0 +1,16 @@ +// import * as cdk from 'aws-cdk-lib'; +// import { Template } from 'aws-cdk-lib/assertions'; +// import * as CdkPipelineDocker from '../lib/cdk-pipeline-docker-stack'; + +// example test. To run these tests, uncomment this file along with the +// example resource in lib/cdk-pipeline-docker-stack.ts +test("SQS Queue Created", () => { + // const app = new cdk.App(); + // // WHEN + // const stack = new CdkPipelineDocker.CdkPipelineDockerStack(app, 'MyTestStack'); + // // THEN + // const template = Template.fromStack(stack); + // template.hasResourceProperties('AWS::SQS::Queue', { + // VisibilityTimeout: 300 + // }); +});