@@ -2,7 +2,7 @@ import { randomUUID } from 'node:crypto';
2
2
import { CfnOutput , Duration } from 'aws-cdk-lib' ;
3
3
import { Tracing } from 'aws-cdk-lib/aws-lambda' ;
4
4
import { NodejsFunction , OutputFormat } from 'aws-cdk-lib/aws-lambda-nodejs' ;
5
- import { RetentionDays } from 'aws-cdk-lib/aws-logs' ;
5
+ import { RetentionDays , LogGroup } from 'aws-cdk-lib/aws-logs' ;
6
6
import type { TestStack } from '../TestStack.js' ;
7
7
import { TEST_ARCHITECTURES , TEST_RUNTIMES } from '../constants.js' ;
8
8
import {
@@ -25,8 +25,17 @@ class TestNodejsFunction extends NodejsFunction {
25
25
) {
26
26
const isESM = extraProps . outputFormat === 'ESM' ;
27
27
const { bundling, ...restProps } = props ;
28
+ const functionName = concatenateResourceName ( {
29
+ testName : stack . testName ,
30
+ resourceName : extraProps . nameSuffix ,
31
+ } ) ;
32
+ const resourceId = randomUUID ( ) . substring ( 0 , 5 ) ;
28
33
29
- super ( stack . stack , `fn-${ randomUUID ( ) . substring ( 0 , 5 ) } ` , {
34
+ const logGroup = new LogGroup ( this , `log-${ resourceId } ` , {
35
+ logGroupName : `/aws/lambda/${ functionName } ` ,
36
+ retention : RetentionDays . ONE_DAY ,
37
+ } ) ;
38
+ super ( stack . stack , `fn-${ resourceId } ` , {
30
39
timeout : Duration . seconds ( 30 ) ,
31
40
memorySize : 512 ,
32
41
tracing : Tracing . ACTIVE ,
@@ -41,13 +50,10 @@ class TestNodejsFunction extends NodejsFunction {
41
50
: '' ,
42
51
} ,
43
52
...restProps ,
44
- functionName : concatenateResourceName ( {
45
- testName : stack . testName ,
46
- resourceName : extraProps . nameSuffix ,
47
- } ) ,
53
+ functionName,
48
54
runtime : TEST_RUNTIMES [ getRuntimeKey ( ) ] ,
49
55
architecture : TEST_ARCHITECTURES [ getArchitectureKey ( ) ] ,
50
- logRetention : RetentionDays . ONE_DAY ,
56
+ logGroup ,
51
57
} ) ;
52
58
53
59
new CfnOutput ( this , extraProps . nameSuffix , {
0 commit comments