Skip to content

Open source AI coding agent. Designed for large projects and real world tasks.

more work on infra cdk script

Dane Schneiderdf02f562b8b6
diff --git a/infra/package-lock.json b/infra/package-lock.json
index 913d129c..eea015f2 100644
--- a/infra/package-lock.json
+++ b/infra/package-lock.json
@@ -9,6 +9,7 @@
"version": "1.0.0",
"dependencies": {
"@aws-cdk/aws-certificatemanager": "^1.204.0",
+ "@aws-cdk/aws-cloudwatch-actions": "^1.204.0",
"@aws-cdk/aws-ec2": "^1.203.0",
"@aws-cdk/aws-ecr": "^1.203.0",
"@aws-cdk/aws-ecs": "^1.203.0",
@@ -315,6 +316,33 @@
"constructs": "^3.3.69"
}
},
+ "node_modules/@aws-cdk/aws-cloudwatch-actions": {
+ "version": "1.204.0",
+ "resolved": "https://registry.npmjs.org/@aws-cdk/aws-cloudwatch-actions/-/aws-cloudwatch-actions-1.204.0.tgz",
+ "integrity": "sha512-Hm8Ux44H1q2ENfhYXrDzZ3aYUY2w21hLDjpoGzyk0qPXAKnHSyDt6dqa4B7/iu5mvVzr7WQnc2bhYbz0hsSEdg==",
+ "deprecated": "AWS CDK v1 has reached End-of-Support on 2023-06-01.\nThis package is no longer being updated, and users should migrate to AWS CDK v2.\n\nFor more information on how to migrate, see https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html",
+ "dependencies": {
+ "@aws-cdk/aws-applicationautoscaling": "1.204.0",
+ "@aws-cdk/aws-autoscaling": "1.204.0",
+ "@aws-cdk/aws-cloudwatch": "1.204.0",
+ "@aws-cdk/aws-iam": "1.204.0",
+ "@aws-cdk/aws-sns": "1.204.0",
+ "@aws-cdk/core": "1.204.0",
+ "constructs": "^3.3.69"
+ },
+ "engines": {
+ "node": ">= 14.15.0"
+ },
+ "peerDependencies": {
+ "@aws-cdk/aws-applicationautoscaling": "1.204.0",
+ "@aws-cdk/aws-autoscaling": "1.204.0",
+ "@aws-cdk/aws-cloudwatch": "1.204.0",
+ "@aws-cdk/aws-iam": "1.204.0",
+ "@aws-cdk/aws-sns": "1.204.0",
+ "@aws-cdk/core": "1.204.0",
+ "constructs": "^3.3.69"
+ }
+ },
"node_modules/@aws-cdk/aws-codeguruprofiler": {
"version": "1.204.0",
"resolved": "https://registry.npmjs.org/@aws-cdk/aws-codeguruprofiler/-/aws-codeguruprofiler-1.204.0.tgz",
diff --git a/infra/package.json b/infra/package.json
index f8bb6f3d..edfa7007 100644
--- a/infra/package.json
+++ b/infra/package.json
@@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"@aws-cdk/aws-certificatemanager": "^1.204.0",
+ "@aws-cdk/aws-cloudwatch-actions": "^1.204.0",
"@aws-cdk/aws-ec2": "^1.203.0",
"@aws-cdk/aws-ecr": "^1.203.0",
"@aws-cdk/aws-ecs": "^1.203.0",
diff --git a/infra/src/main.ts b/infra/src/main.ts
index 02bf48cc..98ca09d5 100644
--- a/infra/src/main.ts
+++ b/infra/src/main.ts
@@ -14,13 +14,18 @@ import * as cloudwatch from "@aws-cdk/aws-cloudwatch";
import * as cloudwatchActions from "@aws-cdk/aws-cloudwatch-actions";
const tag = process.env.STACK_TAG;
-if (!tag) {
- throw new Error("STACK_TAG environment variable is not set");
-}
+const notifyEmail = process.env.NOTIFY_EMAIL;
+const notifySms = process.env.NOTIFY_SMS;
export class PlandexStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
if (!tag) throw new Error("STACK_TAG environment variable is not set");
+ if (!notifyEmail) {
+ throw new Error("NOTIFY_EMAIL environment variable is not set");
+ }
+ if (!notifySms) {
+ throw new Error("NOTIFY_SMS environment variable is not set");
+ }
super(scope, id, props);
@@ -247,10 +252,10 @@ export class PlandexStack extends cdk.Stack {
);
alarmNotificationTopic.addSubscription(
- new subscriptions.EmailSubscription("[email protected]")
+ new subscriptions.EmailSubscription(notifyEmail)
);
alarmNotificationTopic.addSubscription(
- new subscriptions.SmsSubscription("+15555555555")
+ new subscriptions.SmsSubscription(notifySms)
);
const dbCpuUtilizationAlarm = new cloudwatch.Alarm(
@@ -299,12 +304,12 @@ export class PlandexStack extends cdk.Stack {
const dbFreeableMemoryMetric = dbInstance.metricFreeableMemory();
dbFreeableMemoryAlarm.addAlarmAction(
- new cloudwatch.actions.SnsAction(alarmNotificationTopic)
+ new cloudwatchActions.SnsAction(alarmNotificationTopic)
);
new cloudwatch.Alarm(this, "LowDbFreeableMemoryAlarm", {
metric: dbFreeableMemoryMetric,
- threshold: 100 * 1024 * 1024,
+ threshold: 200 * 1024 * 1024,
evaluationPeriods: 2,
alarmDescription: "Alarm when RDS freeable memory is too low",
comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_THRESHOLD,