Skip to content

Commit

Permalink
Enable lambda insights if enabled
Browse files Browse the repository at this point in the history
Introduces a new stack config option `monitoring.lambdaInsightsEnabled`.
  • Loading branch information
unstubbable committed Oct 16, 2023
1 parent e3ccd6c commit f3d25a3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export default () => ({
hostedZoneName: `example.com`,
monitoring: {
accessLoggingEnabled: true, // <==
lambdaInsightsEnabled: true, // <==
loggingEnabled: true, // <==
metricsEnabled: true, // <==
tracingEnabled: true, // <==
Expand Down
20 changes: 15 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@
"typescript": "^5.1.3"
},
"peerDependencies": {
"aws-cdk-lib": "^2.67.0"
"aws-cdk-lib": "^2.87.0"
}
}
6 changes: 6 additions & 0 deletions src/cdk/create-lambda-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export function createLambdaFunction(
);
}

const {monitoring} = stackConfig;

return new aws_lambda.Function(
stack,
`Function${getHash(uniqueFunctionName)}`,
Expand All @@ -66,6 +68,10 @@ export function createLambdaFunction(
timeout: Duration.seconds(timeoutInSeconds),
runtime: aws_lambda.Runtime.NODEJS_18_X,
tracing: aws_lambda.Tracing.PASS_THROUGH,
insightsVersion:
monitoring === true || monitoring?.lambdaInsightsEnabled
? aws_lambda.LambdaInsightsVersion.VERSION_1_0_229_0
: undefined,
logRetention: aws_logs.RetentionDays.TWO_WEEKS,
role: lambdaServiceRole,
},
Expand Down
1 change: 1 addition & 0 deletions src/parse-stack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const StackConfigSchema = DomainNamePartsSchema.extend({
z.literal(true),
z.object({
accessLoggingEnabled: z.boolean().optional(),
lambdaInsightsEnabled: z.boolean().optional(),
loggingEnabled: z.boolean().optional(),
metricsEnabled: z.boolean().optional(),
tracingEnabled: z.boolean().optional(),
Expand Down

0 comments on commit f3d25a3

Please sign in to comment.