Skip to content

Commit

Permalink
Fix export failure alarm for other environments than hahtuva
Browse files Browse the repository at this point in the history
  • Loading branch information
rce committed Nov 25, 2024
1 parent 9cbedd3 commit 45805f3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
15 changes: 8 additions & 7 deletions infra/src/cdk-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,17 @@ class ApplicationStack extends cdk.Stack {
ec2.Port.tcp(database.clusterEndpoint.port)
);

const alarmTopic = sns.Topic.fromTopicArn(
this,
"AlarmTopic",
config.alarmTopicArn
);

const logGroup = new logs.LogGroup(this, "AppLogGroup", {
logGroupName: "kayttooikeus",
retention: logs.RetentionDays.INFINITE,
});
this.exportFailureAlarm(logGroup);
this.exportFailureAlarm(logGroup, alarmTopic);

new AuditLogExport(this, "AuditLogExport", { logGroup });

Expand Down Expand Up @@ -338,12 +344,7 @@ class ApplicationStack extends cdk.Stack {
this.ipRestrictions(alb);
}

exportFailureAlarm(logGroup: logs.LogGroup) {
const alarmTopic = sns.Topic.fromTopicArn(
this,
"AlarmTopic",
ALARM_TOPIC_ARN
);
exportFailureAlarm(logGroup: logs.LogGroup, alarmTopic: sns.ITopic) {
const metricFilter = logGroup.addMetricFilter(
"ExportTaskSuccessMetricFilter",
{
Expand Down
5 changes: 5 additions & 0 deletions infra/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const environments = ["hahtuva", "dev", "qa", "prod"] as const;
type EnvironmentName = (typeof environments)[number];

const defaultConfig = {
alarmTopicArn: "",
minCapacity: 0,
maxCapacity: 0,
// service-provider should run only single instance because it contains in-memory state for SAML message identifiers
Expand Down Expand Up @@ -32,24 +33,28 @@ export function getConfig(): Config {

export const hahtuva: Config = {
...defaultConfig,
alarmTopicArn: "arn:aws:sns:eu-west-1:471112979851:alarm",
minCapacity: 1,
maxCapacity: 2,
};

export const dev: Config = {
...defaultConfig,
alarmTopicArn: "arn:aws:sns:eu-west-1:058264235340:alarm",
minCapacity: 1,
maxCapacity: 2,
};

export const qa: Config = {
...defaultConfig,
alarmTopicArn: "arn:aws:sns:eu-west-1:730335317715:alarm",
minCapacity: 1,
maxCapacity: 2,
};

export const prod: Config = {
...defaultConfig,
alarmTopicArn: "arn:aws:sns:eu-west-1:767397734142:alarm",
minCapacity: 2,
maxCapacity: 8,
};

0 comments on commit 45805f3

Please sign in to comment.