Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/dashboard/widget/BitmapWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import * as path from "path";
import { Duration, Tags } from "aws-cdk-lib";
import { IWidget } from "aws-cdk-lib/aws-cloudwatch";
import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
import { Code, Function, IFunction, Runtime } from "aws-cdk-lib/aws-lambda";
import {
Code,
determineLatestNodeRuntime,
Function,
IFunction,
} from "aws-cdk-lib/aws-lambda";
import { RetentionDays } from "aws-cdk-lib/aws-logs";
import { Construct } from "constructs";

Expand Down Expand Up @@ -34,7 +39,7 @@ export class BitmapWidgetRenderingSupport extends Construct {
"Custom Widget Render for Bitmap Widgets (cdk-monitoring-constructs)",
handler: "index.handler",
memorySize: 128,
runtime: Runtime.NODEJS_LATEST,
runtime: determineLatestNodeRuntime(this),
timeout: Duration.seconds(60),
logRetention: RetentionDays.ONE_DAY,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { Duration, Names } from "aws-cdk-lib";
import { Rule, RuleTargetInput, Schedule } from "aws-cdk-lib/aws-events";
import { LambdaFunction } from "aws-cdk-lib/aws-events-targets";
import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
import { Code, Function, IFunction, Runtime } from "aws-cdk-lib/aws-lambda";
import {
Code,
determineLatestNodeRuntime,
Function,
IFunction,
} from "aws-cdk-lib/aws-lambda";
import { RetentionDays } from "aws-cdk-lib/aws-logs";
import { ISecret } from "aws-cdk-lib/aws-secretsmanager";
import { Construct } from "constructs";
Expand Down Expand Up @@ -34,7 +39,7 @@ export class SecretsManagerMetricsPublisher extends Construct {
"Custom metrics publisher for SecretsManager Secrets (cdk-monitoring-constructs)",
handler: "index.handler",
memorySize: 128,
runtime: Runtime.NODEJS_LATEST,
runtime: determineLatestNodeRuntime(this),
timeout: Duration.seconds(60),
logRetention: RetentionDays.ONE_DAY,
});
Expand Down
12 changes: 8 additions & 4 deletions test/common/alarm/action/LambdaAlarmActionStrategy.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { Stack } from "aws-cdk-lib";
import { Template } from "aws-cdk-lib/assertions";
import { Alarm, Metric } from "aws-cdk-lib/aws-cloudwatch";
import { Function, InlineCode, Runtime } from "aws-cdk-lib/aws-lambda";
import {
determineLatestNodeRuntime,
Function,
InlineCode,
} from "aws-cdk-lib/aws-lambda";

import { LambdaAlarmActionStrategy } from "../../../../lib";

test("snapshot test: Lambda function", () => {
const stack = new Stack();
const onAlarmFunction = new Function(stack, "alarmLambda", {
functionName: "DummyLambda",
runtime: Runtime.NODEJS_LATEST,
runtime: determineLatestNodeRuntime(stack),
code: InlineCode.fromInline("{}"),
handler: "Dummy::handler",
});
Expand All @@ -28,7 +32,7 @@ test("snapshot test: Lambda alias", () => {
const stack = new Stack();
const onAlarmFunction = new Function(stack, "alarmLambda", {
functionName: "DummyLambda",
runtime: Runtime.NODEJS_LATEST,
runtime: determineLatestNodeRuntime(stack),
code: InlineCode.fromInline("{}"),
handler: "Dummy::handler",
});
Expand All @@ -48,7 +52,7 @@ test("snapshot test: Lambda version", () => {
const stack = new Stack();
const onAlarmFunction = new Function(stack, "alarmLambda", {
functionName: "DummyLambda",
runtime: Runtime.NODEJS_LATEST,
runtime: determineLatestNodeRuntime(stack),
code: InlineCode.fromInline("{}"),
handler: "Dummy::handler",
});
Expand Down

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

9 changes: 6 additions & 3 deletions test/dashboard/widget/CustomWidget.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { Stack } from "aws-cdk-lib";
import { Code, Function, Runtime } from "aws-cdk-lib/aws-lambda";
import {
Code,
determineLatestNodeRuntime,
Function,
} from "aws-cdk-lib/aws-lambda";

import { CustomWidget } from "../../../lib/dashboard/widget/CustomWidget";

test("widget", () => {
const stack = new Stack();

const handler = new Function(stack, "Function", {
// execution environment
runtime: Runtime.NODEJS_LATEST,
runtime: determineLatestNodeRuntime(stack),
// code loaded from "lambda" directory
code: Code.fromInline(
'exports.handler = function(event, ctx, cb) { return cb(null, "Hello World!"); }',
Expand Down
10 changes: 9 additions & 1 deletion test/dashboard/widget/__snapshots__/BitmapWidget.test.ts.snap

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

10 changes: 9 additions & 1 deletion test/facade/__snapshots__/MonitoringAspect.test.ts.snap

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

22 changes: 11 additions & 11 deletions test/monitoring/aws-lambda/LambdaFunctionMonitoring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { Duration, Stack } from "aws-cdk-lib";
import { Template } from "aws-cdk-lib/assertions";
import { Color, ComparisonOperator } from "aws-cdk-lib/aws-cloudwatch";
import {
determineLatestNodeRuntime,
Function,
InlineCode,
LayerVersion,
Runtime,
} from "aws-cdk-lib/aws-lambda";

import { AlarmWithAnnotation, LambdaFunctionMonitoring } from "../../../lib";
Expand All @@ -19,7 +19,7 @@ test("snapshot test: default iterator and no alarms", () => {

const lambdaFunction = new Function(stack, "Function", {
functionName: "DummyLambda",
runtime: Runtime.NODEJS_LATEST,
runtime: determineLatestNodeRuntime(stack),
code: InlineCode.fromInline("{}"),
handler: "Dummy::handler",
});
Expand Down Expand Up @@ -49,7 +49,7 @@ test("snapshot test: non-iterator and no alarms", () => {

const lambdaFunction = new Function(stack, "Function", {
functionName: "DummyLambda",
runtime: Runtime.NODEJS_LATEST,
runtime: determineLatestNodeRuntime(stack),
code: InlineCode.fromInline("{}"),
handler: "Dummy::handler",
});
Expand All @@ -72,7 +72,7 @@ test("snapshot test: all alarms", () => {

const lambdaFunction = new Function(stack, "Function", {
functionName: "DummyLambda",
runtime: Runtime.NODEJS_LATEST,
runtime: determineLatestNodeRuntime(stack),
code: InlineCode.fromInline("{}"),
handler: "Dummy::handler",
});
Expand Down Expand Up @@ -190,7 +190,7 @@ test("snapshot test: all alarms", () => {

const lambdaFunction = new Function(stack, "Function", {
functionName: "DummyLambda",
runtime: Runtime.NODEJS_LATEST,
runtime: determineLatestNodeRuntime(stack),
code: InlineCode.fromInline("{}"),
handler: "Dummy::handler",
layers: [
Expand Down Expand Up @@ -230,7 +230,7 @@ test("snapshot test: all alarms, alarmPrefix on error dedupeString", () => {

const lambdaFunction = new Function(stack, "Function", {
functionName: "DummyLambda",
runtime: Runtime.NODEJS_LATEST,
runtime: determineLatestNodeRuntime(stack),
code: InlineCode.fromInline("{}"),
handler: "Dummy::handler",
});
Expand Down Expand Up @@ -376,7 +376,7 @@ test("snapshot test: all alarms, alarmPrefix on latency dedupeString", () => {

const lambdaFunction = new Function(stack, "Function", {
functionName: "DummyLambda",
runtime: Runtime.NODEJS_LATEST,
runtime: determineLatestNodeRuntime(stack),
code: InlineCode.fromInline("{}"),
handler: "Dummy::handler",
});
Expand Down Expand Up @@ -519,7 +519,7 @@ test("throws error if attempting to create iterator age alarm if not an iterator

const lambdaFunction = new Function(stack, "Function", {
functionName: "DummyLambda",
runtime: Runtime.NODEJS_LATEST,
runtime: determineLatestNodeRuntime(stack),
code: InlineCode.fromInline("{}"),
handler: "Dummy::handler",
});
Expand Down Expand Up @@ -549,7 +549,7 @@ test("throws error if attempting to create offsetLag alarm if not an offsetLag L

const lambdaFunction = new Function(stack, "Function", {
functionName: "DummyLambda",
runtime: Runtime.NODEJS_LATEST,
runtime: determineLatestNodeRuntime(stack),
code: InlineCode.fromInline("{}"),
handler: "Dummy::handler",
});
Expand Down Expand Up @@ -578,7 +578,7 @@ test("doesn't create alarms for enhanced Lambda Insights metrics if not enabled"

const lambdaFunction = new Function(stack, "Function", {
functionName: "DummyLambda",
runtime: Runtime.NODEJS_LATEST,
runtime: determineLatestNodeRuntime(stack),
code: InlineCode.fromInline("{}"),
handler: "Dummy::handler",
});
Expand Down Expand Up @@ -689,7 +689,7 @@ test("snapshot test: latency alarms with percentage of timeout with specific tim

const lambdaFunction = new Function(stack, "Function", {
functionName: "DummyLambda",
runtime: Runtime.NODEJS_18_X,
runtime: determineLatestNodeRuntime(stack),
code: InlineCode.fromInline("{}"),
handler: "Dummy::handler",
timeout: Duration.seconds(100),
Expand Down
Loading