diff --git a/serverless/src/index.ts b/serverless/src/index.ts index a50e09d..85004ff 100644 --- a/serverless/src/index.ts +++ b/serverless/src/index.ts @@ -55,6 +55,7 @@ export interface FunctionProperties { TracingConfig?: { [key: string]: string }; FunctionName?: string; Architectures?: [string]; + PackageType?: string; } export const handler = async (event: InputEvent, _: any) => { diff --git a/serverless/src/layer.ts b/serverless/src/layer.ts index e6b0722..289f6fa 100644 --- a/serverless/src/layer.ts +++ b/serverless/src/layer.ts @@ -120,6 +120,12 @@ export function findLambdas(resources: Resources, templateParameterValues: Param } const properties: FunctionProperties = resource.Properties; + + if (properties.PackageType == "Image") { + log.debug(`Resource ${key} is an image based Lambda function, skipping...`); + return; + } + const runtime = useOrRef(properties.Runtime, templateParameterValues); const architecture = useOrRef(properties.Architectures?.[0], templateParameterValues) ?? "x86_64"; diff --git a/serverless/test/layer.spec.ts b/serverless/test/layer.spec.ts index 5c79999..25c61af 100644 --- a/serverless/test/layer.spec.ts +++ b/serverless/test/layer.spec.ts @@ -12,7 +12,7 @@ import { getNewLayers, } from "../src/layer"; -function mockFunctionResource(runtime: string | { Ref: string }, architectures?: string[]) { +function mockFunctionResource(runtime: string | { Ref: string }, architectures?: string[], packageType?: string) { return { Type: "AWS::Lambda::Function", Properties: { @@ -20,6 +20,7 @@ function mockFunctionResource(runtime: string | { Ref: string }, architectures?: Role: "role-arn", Runtime: runtime, Architectures: architectures, + ...(packageType && { PackageType: packageType }), // set PackageType property if available }, }; } @@ -100,6 +101,17 @@ describe("findLambdas", () => { }), ]); }); + + it("skips lambdas that are image based", () => { + const resources = { + Python39Function: mockFunctionResource("python3.9", ["x86_64"]), + Python39ImageFunction: mockFunctionResource("python3.9", ["x86_64"], "Image"), + }; + const lambdas = findLambdas(resources, {}); + expect(lambdas).toEqual([ + mockLambdaFunction("Python39Function", "python3.9", RuntimeType.PYTHON, "x86_64", ArchitectureType.x86_64), + ]); + }); }); describe("applyLayers", () => {