From 9ca8e3aa0f911de2f2bbec6fa0307e69630738ba Mon Sep 17 00:00:00 2001 From: Cristopher Pinzon Date: Thu, 5 Mar 2026 15:06:54 -0500 Subject: [PATCH] image consolidation into pro --- .github/workflows/ci.yml | 9 ++++++--- README.md | 5 ++++- docker-compose.yml | 3 ++- package.json | 2 +- src/index.js | 14 ++++++++++++++ 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 983bea2..537a2a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,10 +54,13 @@ jobs: fi - name: Start LocalStack + env: + LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} run: | - pip install localstack awscli-local[ver1] - docker pull localstack/localstack - localstack start -d + pip install localstack + docker pull localstack/localstack-pro + localstack auth set-token $LOCALSTACK_AUTH_TOKEN + localstack start -d localstack wait -t 30 - name: Run Lint and Test diff --git a/README.md b/README.md index aba064e..fe0063b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This plugin allows Serverless applications to be deployed and tested on your local machine. Any requests to AWS to be redirected to a running LocalStack instance. Pre-requisites: -* LocalStack +* LocalStack Pro (requires `LOCALSTACK_AUTH_TOKEN` environment variable) ## Installation @@ -56,6 +56,7 @@ custom: # Enable this flag to run "docker ..." commands as sudo sudo: False compose_file: /home/localstack_compose.yml # optional to use docker compose instead of docker or localstack cli + image: localstack/localstack-pro # Docker image to use stages: local: ... @@ -64,6 +65,7 @@ custom: ### Configuration via environment variables The following environment variables can be configured (taking precedence over the values in `serverless.yml`): +* `LOCALSTACK_AUTH_TOKEN`: **Required.** Your LocalStack auth token for LocalStack Pro. Obtain one from [LocalStack](https://app.localstack.cloud/). * `AWS_ENDPOINT_URL`: LocalStack endpoint URL to connect to (default: `http://localhost:4566`). This is the recommended configuration, and replaces the deprecated config options (`EDGE_PORT`/`LOCALSTACK_HOSTNAME`/`USE_SSL`) below. * `EDGE_PORT`: LocalStack edge port to connect to (deprecated; default: `4566`) * `LOCALSTACK_HOSTNAME`: LocalStack host name to connect to (deprecated; default: `localhost`) @@ -208,6 +210,7 @@ custom: ``` ## Change Log +* v1.4.0: Use LocalStack Pro image (`localstack/localstack-pro`) by default, require `LOCALSTACK_AUTH_TOKEN`. Addition of `image` config var * 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` diff --git a/docker-compose.yml b/docker-compose.yml index cdc4442..73322b8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,13 +3,14 @@ version: "3.8" services: localstack: container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-main}" - image: localstack/localstack + image: localstack/localstack-pro ports: - "127.0.0.1:4566:4566" # LocalStack Gateway - "127.0.0.1:4510-4559:4510-4559" # external services port range environment: # LocalStack configuration: https://docs.localstack.cloud/references/configuration/ - DEBUG=${DEBUG:-0} + - LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN:?LOCALSTACK_AUTH_TOKEN must be set} volumes: - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack" - "/var/run/docker.sock:/var/run/docker.sock" diff --git a/package.json b/package.json index e0d27a8..9282a41 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "serverless-localstack", - "version": "1.3.1", + "version": "1.4.0", "description": "Connect Serverless to LocalStack!", "main": "src/index.js", "scripts": { diff --git a/src/index.js b/src/index.js index a56318d..7356b39 100644 --- a/src/index.js +++ b/src/index.js @@ -27,6 +27,9 @@ const TYPESCRIPT_PLUGIN_BUILD_DIR_BUILTIN_ESBUILD = '.serverless/build'; //TODO // Default AWS endpoint URL const DEFAULT_AWS_ENDPOINT_URL = 'http://localhost:4566'; +// Default LocalStack Image +const LOCALSTACK_PRO_IMAGE = 'localstack/localstack-pro'; + // Cache hostname to avoid unnecessary connection checks let resolvedHostname = undefined; @@ -425,6 +428,10 @@ class LocalstackPlugin { shouldRunDockerSudo() { return (this.config.docker || {}).sudo; } + + getLocalstackImage(){ + return (this.config.image || process.env.IMAGE_NAME || LOCALSTACK_PRO_IMAGE); + } getStageVariable() { const customConfig = this.serverless.service.custom || {}; @@ -531,10 +538,17 @@ class LocalstackPlugin { env.LAMBDA_REMOTE_DOCKER = env.LAMBDA_REMOTE_DOCKER || '0'; env.DOCKER_FLAGS = (env.DOCKER_FLAGS || '') + ` -v ${cwd}:${cwd}`; env.START_WEB = env.START_WEB || '0'; + if (!env.LOCALSTACK_AUTH_TOKEN) { + this.log('Warning: LOCALSTACK_AUTH_TOKEN is not set. LocalStack Pro requires an auth token.'); + } const maxBuffer = +env.EXEC_MAXBUFFER || 50 * 1000 * 1000; // 50mb buffer to handle output if (this.shouldRunDockerSudo()) { env.DOCKER_CMD = 'sudo docker'; } + + + env.IMAGE_NAME = this.getLocalstackImage(); + const options = { env: env, maxBuffer }; return exec('localstack start -d', options) .then(getContainer)