Skip to content

Commit 6b54636

Browse files
authored
feat: switch to LocalStack Pro image (#286)
1 parent 0b95d2c commit 6b54636

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,13 @@ jobs:
5454
fi
5555
5656
- name: Start LocalStack
57+
env:
58+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
5759
run: |
58-
pip install localstack awscli-local[ver1]
59-
docker pull localstack/localstack
60-
localstack start -d
60+
pip install localstack
61+
docker pull localstack/localstack-pro
62+
localstack auth set-token $LOCALSTACK_AUTH_TOKEN
63+
localstack start -d
6164
localstack wait -t 30
6265
6366
- name: Run Lint and Test

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
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.
88

99
Pre-requisites:
10-
* LocalStack
10+
* LocalStack Pro (requires `LOCALSTACK_AUTH_TOKEN` environment variable)
1111

1212
## Installation
1313

@@ -56,6 +56,7 @@ custom:
5656
# Enable this flag to run "docker ..." commands as sudo
5757
sudo: False
5858
compose_file: /home/localstack_compose.yml # optional to use docker compose instead of docker or localstack cli
59+
image: localstack/localstack-pro # Docker image to use
5960
stages:
6061
local:
6162
...
@@ -64,6 +65,7 @@ custom:
6465
### Configuration via environment variables
6566

6667
The following environment variables can be configured (taking precedence over the values in `serverless.yml`):
68+
* `LOCALSTACK_AUTH_TOKEN`: Your LocalStack auth token for LocalStack Pro. Obtain one from [LocalStack](https://app.localstack.cloud/).
6769
* `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.
6870
* `EDGE_PORT`: LocalStack edge port to connect to (deprecated; default: `4566`)
6971
* `LOCALSTACK_HOSTNAME`: LocalStack host name to connect to (deprecated; default: `localhost`)
@@ -208,6 +210,7 @@ custom:
208210
```
209211
210212
## Change Log
213+
* v1.4.0: Use LocalStack Pro image (`localstack/localstack-pro`) by default. Addition of `image` config var to set a different image
211214
* v1.3.1: prevent the mounting of code if the Lambda uses an ECR Image
212215
* v1.3.0: add support for built-in Esbuild in Serverless Framework v4 #267
213216
* v1.2.1: Fix custom-resource bucket compatibility with serverless >3.39.0, continue improving support for `AWS_ENDPOINT_URL`

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ version: "3.8"
33
services:
44
localstack:
55
container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-main}"
6-
image: localstack/localstack
6+
image: localstack/localstack-pro
77
ports:
88
- "127.0.0.1:4566:4566" # LocalStack Gateway
99
- "127.0.0.1:4510-4559:4510-4559" # external services port range
1010
environment:
1111
# LocalStack configuration: https://docs.localstack.cloud/references/configuration/
1212
- DEBUG=${DEBUG:-0}
13+
- LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN:?LOCALSTACK_AUTH_TOKEN must be set}
1314
volumes:
1415
- "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
1516
- "/var/run/docker.sock:/var/run/docker.sock"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "serverless-localstack",
3-
"version": "1.3.1",
3+
"version": "1.4.0",
44
"description": "Connect Serverless to LocalStack!",
55
"main": "src/index.js",
66
"scripts": {

src/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ const TYPESCRIPT_PLUGIN_BUILD_DIR_BUILTIN_ESBUILD = '.serverless/build'; //TODO
2727
// Default AWS endpoint URL
2828
const DEFAULT_AWS_ENDPOINT_URL = 'http://localhost:4566';
2929

30+
// Default LocalStack Image
31+
const LOCALSTACK_PRO_IMAGE = 'localstack/localstack-pro';
32+
3033
// Cache hostname to avoid unnecessary connection checks
3134
let resolvedHostname = undefined;
3235

@@ -425,6 +428,10 @@ class LocalstackPlugin {
425428
shouldRunDockerSudo() {
426429
return (this.config.docker || {}).sudo;
427430
}
431+
432+
getLocalstackImage(){
433+
return (this.config.image || process.env.IMAGE_NAME || LOCALSTACK_PRO_IMAGE);
434+
}
428435

429436
getStageVariable() {
430437
const customConfig = this.serverless.service.custom || {};
@@ -535,6 +542,10 @@ class LocalstackPlugin {
535542
if (this.shouldRunDockerSudo()) {
536543
env.DOCKER_CMD = 'sudo docker';
537544
}
545+
546+
547+
env.IMAGE_NAME = this.getLocalstackImage();
548+
538549
const options = { env: env, maxBuffer };
539550
return exec('localstack start -d', options)
540551
.then(getContainer)

0 commit comments

Comments
 (0)