Skip to content

Commit

Permalink
Revert "Add CloudWatch notifications and SNS subscriptions" (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
NiallJoeMaher authored Jan 15, 2024
1 parent 45438e0 commit 80240db
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 27 deletions.
27 changes: 0 additions & 27 deletions cdk/lib/app-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
),
);
}
}
16 changes: 16 additions & 0 deletions cdk/test/cdk-pipeline-codu.test.ts
Original file line number Diff line number Diff line change
@@ -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
// });
});

0 comments on commit 80240db

Please sign in to comment.