Skip to content

Commit c97caba

Browse files
mateon01claude
andcommitted
fix(opensearch_ubi): resolve CDK deprecation warnings
- Replace logRetention with explicit logGroup for all Lambda functions - Migrate StateMachine definition to definitionBody - Add installLatestAwsSdkDefault context flag Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 306982a commit c97caba

3 files changed

Lines changed: 37 additions & 6 deletions

File tree

opensearch/opensearch_ubi/cdk.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
]
1818
},
1919
"context": {
20+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
2021
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
2122
"@aws-cdk/core:stackRelativeExports": true,
2223
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true,

opensearch/opensearch_ubi/lib/processing-stack.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ export class ProcessingStack extends cdk.Stack {
145145
// ===========================================================================
146146
// Extract UBI Data Lambda
147147
// ===========================================================================
148+
const extractUbiDataLogGroup = new logs.LogGroup(this, 'ExtractUbiDataLogGroup', {
149+
logGroupName: `/aws/lambda/${envPrefix}-ubi-extract-data`,
150+
retention: logs.RetentionDays.TWO_WEEKS,
151+
removalPolicy: cdk.RemovalPolicy.DESTROY,
152+
});
153+
148154
this.extractUbiDataFunction = new lambda.Function(this, 'ExtractUbiDataFunction', {
149155
functionName: `${envPrefix}-ubi-extract-data`,
150156
description: 'Extract UBI queries and events from OpenSearch',
@@ -160,12 +166,18 @@ export class ProcessingStack extends cdk.Stack {
160166
UBI_EVENTS_INDEX: 'ubi_events',
161167
},
162168
layers: [dependenciesLayer],
163-
logRetention: logs.RetentionDays.TWO_WEEKS,
169+
logGroup: extractUbiDataLogGroup,
164170
});
165171

166172
// ===========================================================================
167173
// Generate Judgments Lambda
168174
// ===========================================================================
175+
const generateJudgmentsLogGroup = new logs.LogGroup(this, 'GenerateJudgmentsLogGroup', {
176+
logGroupName: `/aws/lambda/${envPrefix}-ubi-generate-judgments`,
177+
retention: logs.RetentionDays.TWO_WEEKS,
178+
removalPolicy: cdk.RemovalPolicy.DESTROY,
179+
});
180+
169181
this.generateJudgmentsFunction = new lambda.Function(this, 'GenerateJudgmentsFunction', {
170182
functionName: `${envPrefix}-ubi-generate-judgments`,
171183
description: 'Generate relevance judgments using Claude Sonnet 4.5',
@@ -183,12 +195,18 @@ export class ProcessingStack extends cdk.Stack {
183195
RATE_LIMIT_DELAY: '0.5',
184196
},
185197
layers: [dependenciesLayer],
186-
logRetention: logs.RetentionDays.TWO_WEEKS,
198+
logGroup: generateJudgmentsLogGroup,
187199
});
188200

189201
// ===========================================================================
190202
// Prepare LTR Data Lambda
191203
// ===========================================================================
204+
const prepareLtrDataLogGroup = new logs.LogGroup(this, 'PrepareLtrDataLogGroup', {
205+
logGroupName: `/aws/lambda/${envPrefix}-ubi-prepare-ltr-data`,
206+
retention: logs.RetentionDays.TWO_WEEKS,
207+
removalPolicy: cdk.RemovalPolicy.DESTROY,
208+
});
209+
192210
this.prepareLtrDataFunction = new lambda.Function(this, 'PrepareLtrDataFunction', {
193211
functionName: `${envPrefix}-ubi-prepare-ltr-data`,
194212
description: 'Prepare training data for LTR model',
@@ -204,12 +222,18 @@ export class ProcessingStack extends cdk.Stack {
204222
FEATURE_STORE_INDEX: 'ltr_features',
205223
},
206224
layers: [dependenciesLayer],
207-
logRetention: logs.RetentionDays.TWO_WEEKS,
225+
logGroup: prepareLtrDataLogGroup,
208226
});
209227

210228
// ===========================================================================
211229
// Train LTR Model Lambda
212230
// ===========================================================================
231+
const trainLtrModelLogGroup = new logs.LogGroup(this, 'TrainLtrModelLogGroup', {
232+
logGroupName: `/aws/lambda/${envPrefix}-ubi-train-ltr-model`,
233+
retention: logs.RetentionDays.TWO_WEEKS,
234+
removalPolicy: cdk.RemovalPolicy.DESTROY,
235+
});
236+
213237
this.trainLtrModelFunction = new lambda.Function(this, 'TrainLtrModelFunction', {
214238
functionName: `${envPrefix}-ubi-train-ltr-model`,
215239
description: 'Train and upload LTR model to OpenSearch',
@@ -226,7 +250,7 @@ export class ProcessingStack extends cdk.Stack {
226250
LTR_MODEL_NAME: 'ubi_ltr_model',
227251
},
228252
layers: [dependenciesLayer],
229-
logRetention: logs.RetentionDays.TWO_WEEKS,
253+
logGroup: trainLtrModelLogGroup,
230254
});
231255

232256
// ===========================================================================
@@ -328,7 +352,7 @@ export class ProcessingStack extends cdk.Stack {
328352
// Create the state machine
329353
this.stateMachine = new stepfunctions.StateMachine(this, 'UbiLtrPipeline', {
330354
stateMachineName: `${envPrefix}-ubi-ltr-pipeline`,
331-
definition,
355+
definitionBody: stepfunctions.DefinitionBody.fromChainable(definition),
332356
role: stepFunctionsRole,
333357
timeout: cdk.Duration.hours(2),
334358
tracingEnabled: true,

opensearch/opensearch_ubi/lib/webapp-stack.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ export class WebappStack extends cdk.Stack {
144144
// ===========================================================================
145145
// Note: Dependencies are pre-bundled at lambda/webapp-backend
146146
// Run this to update: cd webapp/backend && pip install --platform manylinux2014_x86_64 --only-binary=:all: -r requirements.txt -t ../../cdk/lambda/webapp-backend && cp main.py ../../cdk/lambda/webapp-backend/
147+
const backendLogGroup = new logs.LogGroup(this, 'BackendLogGroup', {
148+
logGroupName: `/aws/lambda/${envPrefix}-ubi-webapp-backend`,
149+
retention: logs.RetentionDays.TWO_WEEKS,
150+
removalPolicy: cdk.RemovalPolicy.DESTROY,
151+
});
152+
147153
this.backendFunction = new lambda.Function(this, 'BackendFunction', {
148154
functionName: `${envPrefix}-ubi-webapp-backend`,
149155
description: 'FastAPI backend for UBI webapp with SSM/Secrets Manager integration',
@@ -157,7 +163,7 @@ export class WebappStack extends cdk.Stack {
157163
ENV_PREFIX: envPrefix,
158164
AWS_REGION_NAME: region,
159165
},
160-
logRetention: logs.RetentionDays.TWO_WEEKS,
166+
logGroup: backendLogGroup,
161167
});
162168

163169
// ===========================================================================

0 commit comments

Comments
 (0)