Skip to content

Commit 65f3d13

Browse files
authored
Revert "feat: env-specific log retention (prod 90d, staging 60d, dev 30d) (#646)" (#659)
This reverts commit 66d0ca8.
1 parent 913d81a commit 65f3d13

5 files changed

Lines changed: 4 additions & 33 deletions

File tree

bin/stacks/api-stack.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import * as aws_logs from 'aws-cdk-lib/aws-logs'
99
import * as aws_sns from 'aws-cdk-lib/aws-sns'
1010
import * as aws_waf from 'aws-cdk-lib/aws-wafv2'
1111
import { Construct } from 'constructs'
12-
import { STAGE, logRetentionDays } from '../../lib/util/stage'
12+
import { STAGE } from '../../lib/util/stage'
1313
import { SERVICE_NAME } from '../constants'
1414
import { DashboardStack } from './dashboard-stack'
1515
import { IndexCapacityConfig, TableCapacityConfig } from './dynamo-stack'
@@ -74,9 +74,7 @@ export class APIStack extends cdk.Stack {
7474
chatbotSNSArn,
7575
})
7676

77-
const accessLogGroup = new aws_logs.LogGroup(this, `${SERVICE_NAME}APIGAccessLogs`, {
78-
retention: logRetentionDays(stage as STAGE),
79-
})
77+
const accessLogGroup = new aws_logs.LogGroup(this, `${SERVICE_NAME}APIGAccessLogs`)
8078

8179
const api = new aws_apigateway.RestApi(this, `${SERVICE_NAME}`, {
8280
restApiName: `${SERVICE_NAME}`,

bin/stacks/cron-stack.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ import { Construct } from 'constructs'
77
import path from 'path'
88

99
import { SERVICE_NAME, UNIMIND_ALGORITHM_CRON_INTERVAL, FILTER_PATTERNS } from '../constants'
10-
import { STAGE, logRetentionDays } from '../../lib/util/stage'
1110

1211
export interface CronStackProps extends cdk.NestedStackProps {
1312
lambdaRole: aws_iam.Role
14-
stage: STAGE
1513
chatbotSNSArn?: string
1614
envVars?: { [key: string]: string }
1715
}
@@ -37,7 +35,6 @@ export class CronStack extends cdk.NestedStack {
3735
environment: {
3836
NODE_OPTIONS: '--enable-source-maps',
3937
},
40-
logRetention: logRetentionDays(props.stage),
4138
})
4239

4340
new aws_events.Rule(this, `${SERVICE_NAME}UnimindAlgorithmCron`, {

bin/stacks/lambda-stack.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Queue } from 'aws-cdk-lib/aws-sqs'
1212
import { Construct } from 'constructs'
1313
import * as path from 'path'
1414
import { SUPPORTED_CHAINS } from '../../lib/util/chain'
15-
import { STAGE, logRetentionDays } from '../../lib/util/stage'
15+
import { STAGE } from '../../lib/util/stage'
1616
import { SERVICE_NAME, FILTER_PATTERNS } from '../constants'
1717
import { CronStack } from './cron-stack'
1818
import { DynamoStack, IndexCapacityConfig, TableCapacityConfig } from './dynamo-stack'
@@ -146,7 +146,6 @@ export class LambdaStack extends cdk.NestedStack {
146146
},
147147
environment: getOrdersEnv,
148148
tracing: aws_lambda.Tracing.ACTIVE,
149-
logRetention: logRetentionDays(props.stage),
150149
})
151150

152151
this.orderNotificationLambda = new aws_lambda_nodejs.NodejsFunction(this, `OrderNotification${lambdaName}`, {
@@ -172,7 +171,6 @@ export class LambdaStack extends cdk.NestedStack {
172171
vpcSubnets: {
173172
subnets: [...vpc.privateSubnets],
174173
},
175-
logRetention: logRetentionDays(props.stage),
176174
})
177175

178176
const notificationConfig = {
@@ -230,7 +228,6 @@ export class LambdaStack extends cdk.NestedStack {
230228
},
231229
environment: postOrderEnv,
232230
tracing: aws_lambda.Tracing.ACTIVE,
233-
logRetention: logRetentionDays(props.stage),
234231
})
235232

236233
this.postLimitOrderLambda = new aws_lambda_nodejs.NodejsFunction(this, `PostLimitOrder${lambdaName}`, {
@@ -248,7 +245,6 @@ export class LambdaStack extends cdk.NestedStack {
248245
},
249246
environment: postOrderEnv,
250247
tracing: aws_lambda.Tracing.ACTIVE,
251-
logRetention: logRetentionDays(props.stage),
252248
})
253249

254250
this.getLimitOrdersLambda = new aws_lambda_nodejs.NodejsFunction(this, `GetLimitOrders${lambdaName}`, {
@@ -263,7 +259,6 @@ export class LambdaStack extends cdk.NestedStack {
263259
sourceMap: true,
264260
},
265261
environment: getOrdersEnv,
266-
logRetention: logRetentionDays(props.stage),
267262
})
268263

269264
this.getNonceLambda = new aws_lambda_nodejs.NodejsFunction(this, `GetNonce${lambdaName}`, {
@@ -285,7 +280,6 @@ export class LambdaStack extends cdk.NestedStack {
285280
NODE_OPTIONS: '--enable-source-maps',
286281
},
287282
tracing: aws_lambda.Tracing.ACTIVE,
288-
logRetention: logRetentionDays(props.stage),
289283
})
290284

291285
this.getDocsLambda = new aws_lambda_nodejs.NodejsFunction(this, `GetDocs${lambdaName}`, {
@@ -305,7 +299,6 @@ export class LambdaStack extends cdk.NestedStack {
305299
VERSION: '6',
306300
NODE_OPTIONS: '--enable-source-maps',
307301
},
308-
logRetention: logRetentionDays(props.stage),
309302
})
310303

311304
this.getDocsUILambda = new aws_lambda_nodejs.NodejsFunction(this, `GetDocsUI${lambdaName}`, {
@@ -325,7 +318,6 @@ export class LambdaStack extends cdk.NestedStack {
325318
VERSION: '6',
326319
NODE_OPTIONS: '--enable-source-maps',
327320
},
328-
logRetention: logRetentionDays(props.stage),
329321
})
330322

331323
this.getUnimindLambda = new aws_lambda_nodejs.NodejsFunction(this, `GetUnimind${lambdaName}`, {
@@ -341,7 +333,6 @@ export class LambdaStack extends cdk.NestedStack {
341333
},
342334
environment: postOrderEnv,
343335
tracing: aws_lambda.Tracing.ACTIVE,
344-
logRetention: logRetentionDays(props.stage),
345336
})
346337

347338
if (props.envVars['POSTED_ORDER_DESTINATION_ARN']) {
@@ -716,7 +707,6 @@ export class LambdaStack extends cdk.NestedStack {
716707
/* cron stack */
717708
new CronStack(this, `${SERVICE_NAME}CronStack`, {
718709
lambdaRole,
719-
stage: props.stage,
720710
envVars: props.envVars,
721711
chatbotSNSArn: props.chatbotSNSArn,
722712
})

bin/stacks/step-function-stack.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Construct } from 'constructs'
77
import path from 'path'
88
import { checkDefined } from '../../lib/preconditions/preconditions'
99
import { SUPPORTED_CHAINS } from '../../lib/util/chain'
10-
import { STAGE, logRetentionDays } from '../../lib/util/stage'
10+
import { STAGE } from '../../lib/util/stage'
1111
import { SERVICE_NAME, FILTER_PATTERNS } from '../constants'
1212
import orderStatusTrackingStateMachine from '../definitions/order-tracking-sfn.json'
1313

@@ -53,7 +53,6 @@ export class StepFunctionStack extends cdk.NestedStack {
5353
...props.envVars,
5454
stage: stage,
5555
},
56-
logRetention: logRetentionDays(stage),
5756
})
5857
this.checkStatusFunction = checkStatusFunction
5958

lib/util/stage.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
1-
import { RetentionDays } from 'aws-cdk-lib/aws-logs'
2-
31
export enum STAGE {
42
BETA = 'beta',
53
PROD = 'prod',
64
LOCAL = 'local',
75
}
8-
9-
export function logRetentionDays(stage: STAGE): RetentionDays {
10-
switch (stage) {
11-
case STAGE.PROD:
12-
return RetentionDays.THREE_MONTHS
13-
case STAGE.BETA:
14-
return RetentionDays.TWO_MONTHS
15-
default:
16-
return RetentionDays.ONE_MONTH
17-
}
18-
}

0 commit comments

Comments
 (0)