Skip to content

Commit

Permalink
feat: adding alarm that monitors %xx errors in IAM
Browse files Browse the repository at this point in the history
  • Loading branch information
nutrina committed Nov 15, 2024
1 parent fcfdd67 commit bb1c989
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions infra/aws/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as aws from "@pulumi/aws";
import * as op from "@1password/op-js";
import * as cloudflare from "@pulumi/cloudflare";
import { secretsManager, amplify } from "infra-libs";
import {stack, defaultTags} from "../lib/tags";
import { stack, defaultTags } from "../lib/tags";

const current = aws.getCallerIdentity({});
const regionData = aws.getRegion({});
Expand Down Expand Up @@ -40,8 +40,6 @@ const snsAlertsTopicArn = coreInfraStack.getOutput("snsAlertsTopicArn");
const passportXyzDomainName = coreInfraStack.getOutput("passportXyzDomainName");
const passportXyzHostedZoneId = coreInfraStack.getOutput("passportXyzHostedZoneId");



const containerInsightsStatus = stack == "production" ? "enabled" : "disabled";

// Manage secrets & envs for Passport XYZ
Expand Down Expand Up @@ -309,6 +307,30 @@ const albPassportXyzTargetGroup = new aws.lb.TargetGroup(`passport-xyz-iam`, {
},
});

/*
* Alarm for monitoring target 5XX errors
*/
const httpsListenerAlbPrefix = albHttpsListenerArn.apply((arn) => arn.split(":").pop());
const http5xxTargetAlarm = new aws.cloudwatch.MetricAlarm(`HTTP-Target-5XX-passport-xyz-iam`, {
tags: { ...defaultTags, Name: `HTTP-Target-5XX-passport-xyz-iam` },
name: `HTTP-Target-5XX-passport-xyz-iam`,
alarmActions: [snsAlertsTopicArn],
okActions: [snsAlertsTopicArn],

period: 60,
statistic: "Sum",

datapointsToAlarm: 3,
evaluationPeriods: 5,

metricName: "HTTPCode_Target_5XX_Count",
namespace: "AWS/ApplicationELB",

comparisonOperator: "GreaterThanThreshold",
threshold: 0,
treatMissingData: "notBreaching",
});

const albPassportXyzListenerRule = new aws.lb.ListenerRule(`passport-xyz-iam-https`, {
listenerArn: albHttpsListenerArn,
priority: 102, // This needs to be grater than the priority number for passport-scroll-badge-service
Expand Down Expand Up @@ -660,7 +682,7 @@ const ecsAutoScalingTargetXyz = new aws.appautoscaling.Target("autoscaling_targe
tags: {
...defaultTags,
Name: "autoscaling_target_xyz",
}
},
});

const ecsAutoScalingPolicyXyz = new aws.appautoscaling.Policy("passport-autoscaling-policy-xyz", {
Expand Down Expand Up @@ -793,7 +815,7 @@ const gitcoinEcsAutoScalingTarget = new aws.appautoscaling.Target("autoscaling_t
tags: {
...defaultTags,
Name: "autoscaling_target",
}
},
});

const gitcoinEcsAutoScalingPolicy = new aws.appautoscaling.Policy("passport-autoscaling-policy", {
Expand Down Expand Up @@ -852,7 +874,8 @@ const amplifyAppInfo = coreInfraStack.getOutput("newPassportDomain").apply((doma
branchName: passportBranches[stack],
environmentVariables: passportXyzAppEnvironment,
tags: { ...defaultTags, Name: `${prefix}.${domainName}` },
buildCommand: "npm install --g [email protected] && lerna bootstrap && rm -rf ../node_modules/@tendermint && npm run build",
buildCommand:
"npm install --g [email protected] && lerna bootstrap && rm -rf ../node_modules/@tendermint && npm run build",
preBuildCommand: "nvm use 20.9.0",
artifactsBaseDirectory: "out",
customRules: [
Expand Down

0 comments on commit bb1c989

Please sign in to comment.