From 90a948344fad36c92edede374349565763cc831e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristopher=20Pinz=C3=B3n?= <18080804+pinzon@users.noreply.github.com> Date: Tue, 5 Nov 2024 10:00:58 -0500 Subject: [PATCH] prevent mounting of code if the function uses an image (#268) --- README.md | 2 ++ example/service/serverless.yml | 2 +- package.json | 2 +- spec/helpers/services.js | 2 +- src/index.js | 4 ++-- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6d24832..aba064e 100644 --- a/README.md +++ b/README.md @@ -208,6 +208,8 @@ custom: ``` ## Change Log +* v1.3.1: prevent the mounting of code if the Lambda uses an ECR Image +* v1.3.0: add support for built-in Esbuild in Serverless Framework v4 #267 * v1.2.1: Fix custom-resource bucket compatibility with serverless >3.39.0, continue improving support for `AWS_ENDPOINT_URL` * v1.2.0: Add docker-compose config and fix autostart when plugin is not active * v1.1.3: Fix replacing host from environment variable `AWS_ENDPOINT_URL` diff --git a/example/service/serverless.yml b/example/service/serverless.yml index ea87fe8..028c48c 100644 --- a/example/service/serverless.yml +++ b/example/service/serverless.yml @@ -4,7 +4,7 @@ provider: name: aws profile: ${opt:profile, self:custom.profile} stage: ${opt:stage, self:custom.defaultStage} - runtime: nodejs16.x + runtime: nodejs20.x lambdaHashingVersion: '20201221' custom: diff --git a/package.json b/package.json index a6ab713..e0d27a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "serverless-localstack", - "version": "1.2.1", + "version": "1.3.1", "description": "Connect Serverless to LocalStack!", "main": "src/index.js", "scripts": { diff --git a/spec/helpers/services.js b/spec/helpers/services.js index 8d8b690..2ab0a40 100644 --- a/spec/helpers/services.js +++ b/spec/helpers/services.js @@ -16,7 +16,7 @@ const defaultConfig = { service: 'aws-nodejs', provider: { name: 'aws', - runtime: 'nodejs12.x', + runtime: 'nodejs20.x', lambdaHashingVersion: '20201221', environment: { LAMBDA_STAGE: diff --git a/src/index.js b/src/index.js index 0b62f25..a56318d 100644 --- a/src/index.js +++ b/src/index.js @@ -198,10 +198,10 @@ class LocalstackPlugin { // Patch plugin methods function compileFunction(functionName) { - if (!this.shouldMountCode()) { + const functionObject = this.serverless.service.getFunction(functionName); + if (functionObject.image || !this.shouldMountCode()) { return compileFunction._functionOriginal.apply(null, arguments); } - const functionObject = this.serverless.service.getFunction(functionName); functionObject.package = functionObject.package || {}; functionObject.package.artifact = __filename; return compileFunction._functionOriginal