Skip to content

Commit

Permalink
feat: adding alarm that monitors %xx errors in IAM (#3060)
Browse files Browse the repository at this point in the history
* feat: adding alarm that monitors %xx errors in IAM

* fix: alarm config for IAM

* fix: naming of variable
  • Loading branch information
nutrina authored Nov 15, 2024
1 parent fcfdd67 commit bd0ceaf
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 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 @@ -31,6 +31,7 @@ const redisConnectionUrl = pulumi.interpolate`${coreInfraStack.getOutput("static
const albDnsName = coreInfraStack.getOutput("coreAlbDns");
const albZoneId = coreInfraStack.getOutput("coreAlbZoneId");
const albHttpsListenerArn = coreInfraStack.getOutput("coreAlbHttpsListenerArn");
const coreAlbArn = coreInfraStack.getOutput("coreAlbArn");

const passportDataScienceStack = new pulumi.StackReference(`passportxyz/passport-data/${stack}`);
const passportDataScienceEndpoint = passportDataScienceStack.getOutput("internalAlbBaseUrl");
Expand All @@ -40,8 +41,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 +308,35 @@ const albPassportXyzTargetGroup = new aws.lb.TargetGroup(`passport-xyz-iam`, {
},
});

/*
* Alarm for monitoring target 5XX errors
*/
const coreAlbArnSuffix = coreAlbArn.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",

dimensions: {
LoadBalancer: coreAlbArnSuffix,
TargetGroup: albPassportXyzTargetGroup.arnSuffix,
},

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 +688,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 +821,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 +880,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 bd0ceaf

Please sign in to comment.