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
12 changes: 0 additions & 12 deletions serverless/src/lambda/layer-catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ export const lambdaLayerCatalog = {
runtimeType: "JAVA",
tracerLayerNames: { x86_64: "dd-trace-java", arm64: "dd-trace-java" },
},
"nodejs12.x": {
runtimeType: "NODE",
tracerLayerNames: { x86_64: "Datadog-Node12-x", arm64: "Datadog-Node12-x" },
},
"nodejs14.x": {
runtimeType: "NODE",
tracerLayerNames: { x86_64: "Datadog-Node14-x", arm64: "Datadog-Node14-x" },
Expand Down Expand Up @@ -90,14 +86,6 @@ export const lambdaLayerCatalog = {
runtimeType: "CUSTOM",
tracerLayerNames: { x86_64: null, arm64: null },
},
"python2.7": {
runtimeType: "PYTHON",
tracerLayerNames: { x86_64: "Datadog-Python27", arm64: null },
},
"python3.6": {
runtimeType: "PYTHON",
tracerLayerNames: { x86_64: "Datadog-Python36", arm64: null },
},
"python3.7": {
runtimeType: "PYTHON",
tracerLayerNames: { x86_64: "Datadog-Python37", arm64: null },
Expand Down
2 changes: 1 addition & 1 deletion serverless/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function mockInputEvent(
Role: {
"Fn::GetAtt": ["HelloWorldFunctionRole", "Arn"],
},
Runtime: "nodejs12.x",
Runtime: "nodejs24.x",
},
},
},
Expand Down
48 changes: 24 additions & 24 deletions serverless/test/lambda/env.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ describe("setEnvConfiguration", () => {
const lambda: LambdaFunction = {
properties: {
Handler: "app.handler",
Runtime: "python2.7",
Runtime: "python3.14",
Role: "role-arn",
Code: {},
},
key: "FunctionKey",
runtimeType: RuntimeType.PYTHON,
runtime: "python2.7",
runtime: "python3.14",
architecture: "x86_64",
architectureType: ArchitectureType.x86_64,
};
Expand Down Expand Up @@ -204,13 +204,13 @@ describe("setEnvConfiguration", () => {
const lambda: LambdaFunction = {
properties: {
Handler: "app.handler",
Runtime: "python2.7",
Runtime: "python3.14",
Role: "role-arn",
Code: {},
},
key: "FunctionKey",
runtimeType: RuntimeType.PYTHON,
runtime: "python2.7",
runtime: "python3.14",
architecture: "x86_64",
architectureType: ArchitectureType.x86_64,
};
Expand Down Expand Up @@ -244,13 +244,13 @@ describe("setEnvConfiguration", () => {
const lambda: LambdaFunction = {
properties: {
Handler: "app.handler",
Runtime: "python2.7",
Runtime: "python3.14",
Role: "role-arn",
Code: {},
},
key: "FunctionKey",
runtimeType: RuntimeType.PYTHON,
runtime: "python2.7",
runtime: "python3.14",
architecture: "x86_64",
architectureType: ArchitectureType.x86_64,
};
Expand Down Expand Up @@ -318,13 +318,13 @@ describe("setEnvConfiguration", () => {
const lambda: LambdaFunction = {
properties: {
Handler: "app.handler",
Runtime: "python2.7",
Runtime: "python3.14",
Role: "role-arn",
Code: {},
},
key: "FunctionKey",
runtimeType: RuntimeType.PYTHON,
runtime: "python2.7",
runtime: "python3.14",
architecture: "x86_64",
architectureType: ArchitectureType.x86_64,
};
Expand Down Expand Up @@ -405,14 +405,14 @@ describe("setEnvConfiguration", () => {
const lambda: LambdaFunction = {
properties: {
Handler: "app.handler",
Runtime: "python2.7",
Runtime: "python3.14",
Role: "role-arn",
Code: {},
Environment: { Variables: originalEnvVars },
},
key: "FunctionKey",
runtimeType: RuntimeType.PYTHON,
runtime: "python2.7",
runtime: "python3.14",
architecture: "x86_64",
architectureType: ArchitectureType.x86_64,
};
Expand Down Expand Up @@ -453,13 +453,13 @@ describe("setEnvConfiguration", () => {
const lambda: LambdaFunction = {
properties: {
Handler: "app.handler",
Runtime: "python2.7",
Runtime: "python3.14",
Role: "role-arn",
Code: {},
},
key: "FunctionKey",
runtimeType: RuntimeType.PYTHON,
runtime: "python2.7",
runtime: "python3.14",
architecture: "x86_64",
architectureType: ArchitectureType.x86_64,
};
Expand Down Expand Up @@ -497,13 +497,13 @@ describe("setEnvConfiguration", () => {
const lambda: LambdaFunction = {
properties: {
Handler: "app.handler",
Runtime: "python2.7",
Runtime: "python3.14",
Role: "role-arn",
Code: {},
},
key: "FunctionKey",
runtimeType: RuntimeType.PYTHON,
runtime: "python2.7",
runtime: "python3.14",
architecture: "x86_64",
architectureType: ArchitectureType.x86_64,
};
Expand Down Expand Up @@ -542,13 +542,13 @@ describe("setEnvConfiguration", () => {
const lambda: LambdaFunction = {
properties: {
Handler: "app.handler",
Runtime: "python2.7",
Runtime: "python3.14",
Role: "role-arn",
Code: {},
},
key: "FunctionKey",
runtimeType: RuntimeType.PYTHON,
runtime: "python2.7",
runtime: "python3.14",
architecture: "x86_64",
architectureType: ArchitectureType.x86_64,
};
Expand Down Expand Up @@ -582,13 +582,13 @@ describe("setEnvConfiguration", () => {
const lambda: LambdaFunction = {
properties: {
Handler: "app.handler",
Runtime: "python2.7",
Runtime: "python3.14",
Role: "role-arn",
Code: {},
},
key: "FunctionKey",
runtimeType: RuntimeType.PYTHON,
runtime: "python2.7",
runtime: "python3.14",
architecture: "x86_64",
architectureType: ArchitectureType.x86_64,
};
Expand Down Expand Up @@ -622,13 +622,13 @@ describe("setEnvConfiguration", () => {
const lambda: LambdaFunction = {
properties: {
Handler: "app.handler",
Runtime: "python2.7",
Runtime: "python3.14",
Role: "role-arn",
Code: {},
},
key: "FunctionKey",
runtimeType: RuntimeType.PYTHON,
runtime: "python2.7",
runtime: "python3.14",
architecture: "x86_64",
architectureType: ArchitectureType.x86_64,
};
Expand Down Expand Up @@ -695,13 +695,13 @@ describe("setEnvConfiguration", () => {
properties: {
FunctionName: "my-function",
Handler: "app.handler",
Runtime: "nodejs12.x",
Runtime: "nodejs24.x",
Role: "role-arn",
Code: {},
},
key: "FunctionKey",
runtimeType: RuntimeType.NODE,
runtime: "nodejs12.x",
runtime: "nodejs24.x",
architecture: "x86_64",
architectureType: ArchitectureType.x86_64,
};
Expand Down Expand Up @@ -776,13 +776,13 @@ describe("setEnvConfiguration", () => {
properties: {
FunctionName: "my-function",
Handler: "app.handler",
Runtime: "nodejs12.x",
Runtime: "nodejs24.x",
Role: "role-arn",
Code: {},
},
key: "FunctionKey",
runtimeType: RuntimeType.NODE,
runtime: "nodejs12.x",
runtime: "nodejs24.x",
architecture: "x86_64",
architectureType: ArchitectureType.x86_64,
};
Expand Down
6 changes: 3 additions & 3 deletions serverless/test/lambda/lambda.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ describe("Lambda", () => {
const output = await handler(inputEvent, {});
const lambdaProperties: FunctionProperties = output.fragment.Resources[LAMBDA_KEY].Properties;

// Mocked Lambda has runtime nodejs12.x, so layer name is Datadog-Node12-x, with provided version number (25) at end
// Mocked Lambda has runtime nodejs24.x, so layer name is Datadog-Node24-x, with provided version number (25) at end
expect(lambdaProperties.Layers).toEqual([
expect.stringMatching(/arn:aws:lambda:us-east-1:.*:layer:Datadog-Node12-x:25/),
expect.stringMatching(/arn:aws:lambda:us-east-1:.*:layer:Datadog-Node24-x:25/),
]);
});

Expand Down Expand Up @@ -98,7 +98,7 @@ describe("Lambda", () => {
const lambdaProperties: FunctionProperties = output.fragment.Resources[LAMBDA_KEY].Properties;

expect(lambdaProperties.Layers).toEqual([
expect.stringMatching(/arn:aws-us-gov:lambda:us-gov-east-1:002406178527:layer:Datadog-Node12-x:25/),
expect.stringMatching(/arn:aws-us-gov:lambda:us-gov-east-1:002406178527:layer:Datadog-Node24-x:25/),
]);
});

Expand Down
44 changes: 19 additions & 25 deletions serverless/test/lambda/layer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ describe("findLambdas", () => {
Java25Function: mockFunctionResource("java25", ["x86_64"]),
Java8Function: mockFunctionResource("java8", ["x86_64"]),
Java8al2Function: mockFunctionResource("java8.al2", ["x86_64"]),
Node12Function: mockFunctionResource("nodejs12.x", ["x86_64"]),
Node14Function: mockFunctionResource("nodejs14.x", ["x86_64"]),
Node16Function: mockFunctionResource("nodejs16.x", ["x86_64"]),
Node18Function: mockFunctionResource("nodejs18.x", ["x86_64"]),
Expand All @@ -70,8 +69,6 @@ describe("findLambdas", () => {
Node24Function: mockFunctionResource("nodejs24.x", ["x86_64"]),
ProvidedAl2Function: mockFunctionResource("provided.al2", ["x86_64"]),
ProvidedAl2023Function: mockFunctionResource("provided.al2023", ["x86_64"]),
Python27Function: mockFunctionResource("python2.7", ["x86_64"]),
Python36Function: mockFunctionResource("python3.6", ["x86_64"]),
Python37Function: mockFunctionResource("python3.7", ["x86_64"]),
Python38Function: mockFunctionResource("python3.8", ["x86_64"]),
Python39Function: mockFunctionResource("python3.9", ["x86_64"]),
Expand Down Expand Up @@ -99,7 +96,6 @@ describe("findLambdas", () => {
mockLambdaFunction("Java25Function", "java25", RuntimeType.JAVA, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Java8Function", "java8", RuntimeType.JAVA, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Java8al2Function", "java8.al2", RuntimeType.JAVA, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Node12Function", "nodejs12.x", RuntimeType.NODE, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Node14Function", "nodejs14.x", RuntimeType.NODE, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Node16Function", "nodejs16.x", RuntimeType.NODE, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Node18Function", "nodejs18.x", RuntimeType.NODE, "x86_64", ArchitectureType.x86_64),
Expand All @@ -114,8 +110,6 @@ describe("findLambdas", () => {
"x86_64",
ArchitectureType.x86_64,
),
mockLambdaFunction("Python27Function", "python2.7", RuntimeType.PYTHON, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Python36Function", "python3.6", RuntimeType.PYTHON, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Python37Function", "python3.7", RuntimeType.PYTHON, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Python38Function", "python3.8", RuntimeType.PYTHON, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Python39Function", "python3.9", RuntimeType.PYTHON, "x86_64", ArchitectureType.x86_64),
Expand Down Expand Up @@ -149,19 +143,19 @@ describe("findLambdas", () => {

describe("applyLayers", () => {
it("adds a layer array if none are present", () => {
const lambda = mockLambdaFunction("FunctionKey", "nodejs12.x", RuntimeType.NODE, "x86_64");
const lambda = mockLambdaFunction("FunctionKey", "nodejs24.x", RuntimeType.NODE, "x86_64");
const region = "us-east-1";
const nodeLayerVersion = 25;
const errors = applyLayers(region, [lambda], undefined, nodeLayerVersion);

expect(errors.length).toEqual(0);
expect(lambda.properties.Layers).toEqual([
`arn:aws:lambda:${region}:${DD_ACCOUNT_ID}:layer:Datadog-Node12-x:${nodeLayerVersion}`,
`arn:aws:lambda:${region}:${DD_ACCOUNT_ID}:layer:Datadog-Node24-x:${nodeLayerVersion}`,
]);
});

it("appends to the layer array if already present", () => {
const lambda = mockLambdaFunction("FunctionKey", "nodejs12.x", RuntimeType.NODE, "x86_64");
const lambda = mockLambdaFunction("FunctionKey", "nodejs24.x", RuntimeType.NODE, "x86_64");
lambda.properties.Layers = ["node:2"];

const region = "us-east-1";
Expand All @@ -171,15 +165,15 @@ describe("applyLayers", () => {
expect(errors.length).toEqual(0);
expect(lambda.properties.Layers).toEqual([
"node:2",
`arn:aws:lambda:${region}:${DD_ACCOUNT_ID}:layer:Datadog-Node12-x:${nodeLayerVersion}`,
`arn:aws:lambda:${region}:${DD_ACCOUNT_ID}:layer:Datadog-Node24-x:${nodeLayerVersion}`,
]);
});

it("doesn't add duplicate layers", () => {
const lambda = mockLambdaFunction("FunctionKey", "nodejs12.x", RuntimeType.NODE, "x86_64");
const lambda = mockLambdaFunction("FunctionKey", "nodejs24.x", RuntimeType.NODE, "x86_64");
const region = "us-east-1";
const nodeLayerVersion = 25;
const layerArn = `arn:aws:lambda:${region}:${DD_ACCOUNT_ID}:layer:Datadog-Node12-x:${nodeLayerVersion}`;
const layerArn = `arn:aws:lambda:${region}:${DD_ACCOUNT_ID}:layer:Datadog-Node24-x:${nodeLayerVersion}`;
lambda.properties.Layers = [layerArn];
const errors = applyLayers(region, [lambda], undefined, nodeLayerVersion);

Expand All @@ -196,8 +190,8 @@ describe("applyLayers", () => {
});

it("returns errors if layer versions are not provided for corresponding Lambda runtimes", () => {
const pythonLambda = mockLambdaFunction("PythonFunctionKey", "python2.7", RuntimeType.PYTHON, "x86_64");
const nodeLambda = mockLambdaFunction("NodeFunctionKey", "nodejs12.x", RuntimeType.NODE, "x86_64");
const pythonLambda = mockLambdaFunction("PythonFunctionKey", "python3.14", RuntimeType.PYTHON, "x86_64");
const nodeLambda = mockLambdaFunction("NodeFunctionKey", "nodejs24.x", RuntimeType.NODE, "x86_64");
const errors = applyLayers("us-east-1", [pythonLambda, nodeLambda]);

expect(errors).toEqual([
Expand Down Expand Up @@ -446,33 +440,33 @@ describe("getNewLayers", () => {
describe("isGovCloud", () => {
it("applies the GovCloud layer", () => {
const pythonLambda = mockLambdaFunction("PythonFunctionKey", "python3.8", RuntimeType.PYTHON, "x86_64");
const nodeLambda = mockLambdaFunction("NodeFunctionKey", "nodejs16.x", RuntimeType.NODE, "x86_64");
const nodeLambda = mockLambdaFunction("NodeFunctionKey", "nodejs24.x", RuntimeType.NODE, "x86_64");
const errors = applyLayers("us-gov-east-1", [pythonLambda, nodeLambda], 21, 30);

expect(errors.length).toEqual(0);
expect(pythonLambda.properties.Layers).toEqual([
`arn:aws-us-gov:lambda:us-gov-east-1:${DD_GOV_ACCOUNT_ID}:layer:Datadog-Python38:21`,
]);
expect(nodeLambda.properties.Layers).toEqual([
`arn:aws-us-gov:lambda:us-gov-east-1:${DD_GOV_ACCOUNT_ID}:layer:Datadog-Node16-x:30`,
`arn:aws-us-gov:lambda:us-gov-east-1:${DD_GOV_ACCOUNT_ID}:layer:Datadog-Node24-x:30`,
]);
});
});

describe("getLambdaLibraryLayerArn", () => {
it("gets the us-east-1 layer arn for the Datadog Node16 Lambda Library", () => {
it("gets the us-east-1 layer arn for the Datadog Node24 Lambda Library", () => {
const region = "us-east-1";
const version = 22;
const runtime = "nodejs16.x";
const runtime = "nodejs24.x";
const layerArn = getLambdaLibraryLayerArn(region, version, runtime, "x86_64");
expect(layerArn).toEqual(`arn:aws:lambda:${region}:${DD_ACCOUNT_ID}:layer:Datadog-Node16-x:${version}`);
expect(layerArn).toEqual(`arn:aws:lambda:${region}:${DD_ACCOUNT_ID}:layer:Datadog-Node24-x:${version}`);
});
it("gets the us-east-1 layer arn for the Datadog Python36 Lambda Library", () => {
it("gets the us-east-1 layer arn for the Datadog Python314 Lambda Library", () => {
const region = "us-east-1";
const version = 22;
const runtime = "python3.6";
const runtime = "python3.14";
const layerArn = getLambdaLibraryLayerArn(region, version, runtime, "x86_64");
expect(layerArn).toEqual(`arn:aws:lambda:${region}:${DD_ACCOUNT_ID}:layer:Datadog-Python36:${version}`);
expect(layerArn).toEqual(`arn:aws:lambda:${region}:${DD_ACCOUNT_ID}:layer:Datadog-Python314:${version}`);
});
it("gets the us-east-1 ARM layer arn for the Datadog Python38 Lambda Library", () => {
const region = "us-east-1";
Expand All @@ -481,12 +475,12 @@ describe("getLambdaLibraryLayerArn", () => {
const layerArn = getLambdaLibraryLayerArn(region, version, runtime, "arm64");
expect(layerArn).toEqual(`arn:aws:lambda:${region}:${DD_ACCOUNT_ID}:layer:Datadog-Python38-ARM:${version}`);
});
it("gets the us-gov-east-1 layer arn for the Datadog Python36 Lambda Library", () => {
it("gets the us-gov-east-1 layer arn for the Datadog Python38 Lambda Library", () => {
const region = "us-gov-east-1";
const version = 22;
const runtime = "python3.6";
const runtime = "python3.8";
const layerArn = getLambdaLibraryLayerArn(region, version, runtime, "x86_64");
expect(layerArn).toEqual(`arn:aws-us-gov:lambda:${region}:${DD_GOV_ACCOUNT_ID}:layer:Datadog-Python36:${version}`);
expect(layerArn).toEqual(`arn:aws-us-gov:lambda:${region}:${DD_GOV_ACCOUNT_ID}:layer:Datadog-Python38:${version}`);
});
it("gets the us-gov-east-1 ARM layer arn for the Datadog Python39 Lambda Library", () => {
const region = "us-gov-east-1";
Expand Down
Loading