Skip to content

Commit

Permalink
Set log retention to two years
Browse files Browse the repository at this point in the history
  • Loading branch information
pkalliok committed Dec 27, 2023
1 parent 527d3eb commit 2c6496f
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 25 deletions.
46 changes: 31 additions & 15 deletions cdk/lib/amis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import iam = require("aws-cdk-lib/aws-iam");
import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
import { CfnEventSourceMapping } from "aws-cdk-lib/aws-lambda";
import {HeratepalveluStack} from "./heratepalvelu";
import { RetentionDays } from "aws-cdk-lib/aws-logs";



Expand Down Expand Up @@ -218,7 +219,8 @@ export class HeratepalveluAMISStack extends HeratepalveluStack {
timeout: Duration.seconds(
Token.asNumber(this.getParameterFromSsm("ehokshandler-timeout"))
),
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

AMISHerateHandler.addEventSource(new SqsEventSource(ehoksHerateQueue, { batchSize: 1, }));
Expand All @@ -238,7 +240,8 @@ export class HeratepalveluAMISStack extends HeratepalveluStack {
timeout: Duration.seconds(
Token.asNumber(this.getParameterFromSsm("ehokshandler-timeout"))
),
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

new CfnEventSourceMapping(this, "ONRhenkilomodifyEventSourceMapping", {
Expand Down Expand Up @@ -274,7 +277,8 @@ export class HeratepalveluAMISStack extends HeratepalveluStack {
handler: "oph.heratepalvelu.util.ONRDLQresendHandler::handleONRDLQresend",
memorySize: 1024,
timeout: Duration.seconds(60),
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

ONRdlqResendHandler.addToRolePolicy(new iam.PolicyStatement({
Expand Down Expand Up @@ -311,7 +315,8 @@ export class HeratepalveluAMISStack extends HeratepalveluStack {
Token.asNumber(this.getParameterFromSsm("emailhandler-timeout"))
),
handler: "oph.heratepalvelu.amis.AMISherateEmailHandler::handleSendAMISEmails",
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

new events.Rule(this, "AMISHerateEmailScheduleRule", {
Expand All @@ -335,7 +340,8 @@ export class HeratepalveluAMISStack extends HeratepalveluStack {
Token.asNumber(this.getParameterFromSsm("emailhandler-timeout"))
),
handler: "oph.heratepalvelu.amis.EmailStatusHandler::handleEmailStatus",
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

new events.Rule(this, "AMISEmailStatusScheduleRule", {
Expand All @@ -359,7 +365,8 @@ export class HeratepalveluAMISStack extends HeratepalveluStack {
Token.asNumber(this.getParameterFromSsm("emailhandler-timeout"))
),
handler: "oph.heratepalvelu.amis.AMISMuistutusHandler::handleSendAMISMuistutus",
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

new events.Rule(this, "AMISMuistutusScheduleRule", {
Expand All @@ -381,7 +388,8 @@ export class HeratepalveluAMISStack extends HeratepalveluStack {
memorySize: 1024,
reservedConcurrentExecutions: 1,
timeout: Duration.seconds(60),
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

AMISEmailResendHandler.addEventSource(new SqsEventSource(ehoksAmisResendQueue, { batchSize: 1, }));
Expand All @@ -401,7 +409,8 @@ export class HeratepalveluAMISStack extends HeratepalveluStack {
Token.asNumber(this.getParameterFromSsm("emailhandler-timeout"))
),
handler: "oph.heratepalvelu.amis.AMISSMSHandler::handleAMISSMS",
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

new events.Rule(this, "AMISSMSScheduleRule", {
Expand Down Expand Up @@ -430,7 +439,8 @@ export class HeratepalveluAMISStack extends HeratepalveluStack {
timeout: Duration.seconds(
Token.asNumber(this.getParameterFromSsm("updatedoohandler-timeout"))
),
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

new events.Rule(this, "UpdatedOoScheduleRule", {
Expand All @@ -452,7 +462,8 @@ export class HeratepalveluAMISStack extends HeratepalveluStack {
handler: "oph.heratepalvelu.util.DLQresendHandler::handleDLQresend",
memorySize: 1024,
timeout: Duration.seconds(60),
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

dlqResendHandler.addToRolePolicy(new iam.PolicyStatement({
Expand Down Expand Up @@ -485,7 +496,8 @@ export class HeratepalveluAMISStack extends HeratepalveluStack {
handler: "oph.heratepalvelu.amis.AMISDeleteTunnusHandler::handleDeleteTunnus",
memorySize: 1024,
timeout: Duration.seconds(60),
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

AMISDeleteTunnusHandler.addEventSource(
Expand All @@ -504,7 +516,8 @@ export class HeratepalveluAMISStack extends HeratepalveluStack {
memorySize: 1024,
reservedConcurrentExecutions: 1,
timeout: Duration.seconds(900),
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

const AMISherateArchive2019_2020Table = new dynamodb.Table(
Expand Down Expand Up @@ -572,7 +585,8 @@ export class HeratepalveluAMISStack extends HeratepalveluStack {
memorySize: Token.asNumber(1024),
timeout: Duration.seconds(900),
handler: "oph.heratepalvelu.amis.AMISehoksTimedOperationsHandler::handleAMISTimedOperations",
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
}
);

Expand All @@ -596,7 +610,8 @@ export class HeratepalveluAMISStack extends HeratepalveluStack {
memorySize: Token.asNumber(1024),
timeout: Duration.seconds(900),
handler: "oph.heratepalvelu.amis.AMISehoksTimedOperationsHandler::handleMassHerateResend",
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
}
);

Expand All @@ -620,7 +635,8 @@ export class HeratepalveluAMISStack extends HeratepalveluStack {
memorySize: Token.asNumber(1024),
timeout: Duration.seconds(900),
handler: "oph.heratepalvelu.amis.AMISehoksTimedOperationsHandler::handleEhoksOpiskeluoikeusUpdate",
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
}
);

Expand Down
28 changes: 19 additions & 9 deletions cdk/lib/tep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import iam = require("aws-cdk-lib/aws-iam");
import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
import { HeratepalveluStack } from "./heratepalvelu";
import { CfnEventSourceMapping } from "aws-cdk-lib/aws-lambda";
import { RetentionDays } from "aws-cdk-lib/aws-logs";

export class HeratepalveluTEPStack extends HeratepalveluStack {
constructor(
Expand Down Expand Up @@ -249,7 +250,8 @@ export class HeratepalveluTEPStack extends HeratepalveluStack {
reservedConcurrentExecutions: 1,
timeout: Duration.seconds(900),
handler: "oph.heratepalvelu.tep.ehoksTimedOperationsHandler::handleTimedOperations",
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

new events.Rule(this, "TimedOperationsScheduleRule", {
Expand Down Expand Up @@ -280,7 +282,8 @@ export class HeratepalveluTEPStack extends HeratepalveluStack {
timeout: Duration.seconds(
Token.asNumber(this.getParameterFromSsm("jaksohandler-timeout"))
),
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

jaksoHandler.addEventSource(new SqsEventSource(herateQueue, { batchSize: 1 }));
Expand All @@ -303,7 +306,8 @@ export class HeratepalveluTEPStack extends HeratepalveluStack {
reservedConcurrentExecutions: 1,
timeout: Duration.seconds(900),
handler: "oph.heratepalvelu.tep.niputusHandler::handleNiputus",
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

new events.Rule(this, "niputusHandlerScheduleRule", {
Expand Down Expand Up @@ -332,7 +336,8 @@ export class HeratepalveluTEPStack extends HeratepalveluStack {
reservedConcurrentExecutions: 1,
timeout: Duration.seconds(300),
handler: "oph.heratepalvelu.tep.emailHandler::handleSendTEPEmails",
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

new events.Rule(this, "emailHandlerScheduleRule", {
Expand All @@ -358,7 +363,8 @@ export class HeratepalveluTEPStack extends HeratepalveluStack {
reservedConcurrentExecutions: 1,
timeout: Duration.seconds(300),
handler: "oph.heratepalvelu.tep.StatusHandler::handleEmailStatus",
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

new events.Rule(this, "TEPEmailStatusScheduleRule", {
Expand Down Expand Up @@ -386,7 +392,8 @@ export class HeratepalveluTEPStack extends HeratepalveluStack {
timeout: Duration.seconds(
Token.asNumber(this.getParameterFromSsm("smshandler-timeout"))
),
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

new events.Rule(this, "SMSscheduleRule", {
Expand Down Expand Up @@ -416,7 +423,8 @@ export class HeratepalveluTEPStack extends HeratepalveluStack {
Token.asNumber(this.getParameterFromSsm("emailhandler-timeout"))
),
handler: "oph.heratepalvelu.tep.EmailMuistutusHandler::handleSendEmailMuistutus",
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

nippuTable.grantReadWriteData(EmailMuistutusHandler);
Expand Down Expand Up @@ -448,7 +456,8 @@ export class HeratepalveluTEPStack extends HeratepalveluStack {
timeout: Duration.seconds(
Token.asNumber(this.getParameterFromSsm("emailhandler-timeout"))
),
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

nippuTable.grantReadWriteData(SmsMuistutusHandler);
Expand All @@ -472,7 +481,8 @@ export class HeratepalveluTEPStack extends HeratepalveluStack {
handler: "oph.heratepalvelu.util.DLQresendHandler::handleDLQresend",
memorySize: 1024,
timeout: Duration.seconds(60),
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

dlqResendHandler.addToRolePolicy(new iam.PolicyStatement({
Expand Down
4 changes: 3 additions & 1 deletion cdk/lib/teprah.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import sqs = require("aws-cdk-lib/aws-sqs");
import iam = require("aws-cdk-lib/aws-iam");
import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
import { HeratepalveluStack } from "./heratepalvelu";
import { RetentionDays } from "aws-cdk-lib/aws-logs";

export class HeratepalveluTEPRAHOITUSStack extends HeratepalveluStack {
constructor(
Expand Down Expand Up @@ -86,7 +87,8 @@ export class HeratepalveluTEPRAHOITUSStack extends HeratepalveluStack {
memorySize: 1024,
reservedConcurrentExecutions: 2, //fixme, parametrit kuntoon
timeout: Duration.seconds(80),
tracing: lambda.Tracing.ACTIVE
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

rahoitusResultsHandler.addEventSource(new SqsEventSource(tepRahoitusQueue, { batchSize: 1 }));
Expand Down
3 changes: 3 additions & 0 deletions cdk/lib/tpk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import lambda = require("aws-cdk-lib/aws-lambda");
import s3assets = require("aws-cdk-lib/aws-s3-assets");
import iam = require("aws-cdk-lib/aws-iam");
import { HeratepalveluStack } from "./heratepalvelu";
import { RetentionDays } from "aws-cdk-lib/aws-logs";

export class HeratepalveluTPKStack extends HeratepalveluStack {
constructor(
Expand Down Expand Up @@ -74,6 +75,7 @@ export class HeratepalveluTPKStack extends HeratepalveluStack {
timeout: Duration.seconds(900),
handler: "oph.heratepalvelu.tpk.tpkNiputusHandler::handleTpkNiputus",
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

tepJaksotunnusTable.grantReadWriteData(tpkNiputusHandler);
Expand Down Expand Up @@ -106,6 +108,7 @@ export class HeratepalveluTPKStack extends HeratepalveluStack {
timeout: Duration.seconds(900),
handler: "oph.heratepalvelu.tpk.tpkArvoCallHandler::handleTpkArvoCalls",
tracing: lambda.Tracing.ACTIVE,
logRetention: RetentionDays.TWO_YEARS
});

tpkNippuTable.grantReadWriteData(tpkArvoCallHandler);
Expand Down

0 comments on commit 2c6496f

Please sign in to comment.