diff --git a/README.md b/README.md index bac890e..181918b 100644 --- a/README.md +++ b/README.md @@ -19,21 +19,22 @@ A Template can be used in a new or existing project, and a [supporting tool](htt To use either of the Templates use a supported tool and choose one of them, then either add custom values to the options or keep the defaults. Alternatively, copy the contents of the desired Template's `.devcontainer` folder and customize it as necessary. -Both variation of the Templates adds automatically the [official LocalStack DevContainer Feature](https://github.com/localstack/devcontainer-feature), which installs the CLI and by demand the most popular *Local Tools™*. -Currently this calls for a **Debian-based** DevContainer image. +Both Templates install [lstk](https://github.com/localstack/lstk), the LocalStack CLI. Besides managing LocalStack, lstk proxies `aws`, `terraform`, `cdk`, `sam` and `az` commands to LocalStack (e.g. `lstk aws s3 ls`). The wrapped tools themselves need to be added separately, e.g. via the `ghcr.io/devcontainers/features/aws-cli` Feature. ### LocalStack - Docker-in-Docker This version of the Template starts up LocalStack in an internal Docker service in the DevContainer, hence we set a volume by default for data persistence. As a result the newly built DevContainers do not necessarily need to re-download images as long this volume exists on the system. -Additionally the DevContainer bind mounts a folder from the host system as `/data`, which will be used to store LocalStack data (`LOCALSTACK_VOLUME_DIR`). +Additionally the DevContainer bind mounts a folder from the host system as `/data`, which will be used to store LocalStack data. -LocalStack in this variation is controlled via the LocalStack CLI and some env variables that you can adjust or expand in the `devcontainer.json` file's `remoteEnv` block. +LocalStack in this variation is started with `lstk start` after the DevContainer is created and is controlled with lstk (`lstk status`, `lstk stop`, `lstk logs`, ...). +The image version and the LocalStack configuration live in `.devcontainer/lstk.toml`, which is linked as the lstk config (`~/.config/lstk/config.toml`); add further LocalStack variables to its `[env.devcontainer]` section. For further LocalStack configuration options please consult our [official documentation](https://docs.localstack.cloud/references/configuration/). -#### Use LocalStack Pro +#### Auth Token -Set `usePro: true` and set on your host system the `LOCALSTACK_AUTH_TOKEN` or the `LOCALSTACK_API_KEY` environment variable, this will be automatically picked up by the Template. +An Auth Token is required to start LocalStack. Set the `LOCALSTACK_AUTH_TOKEN` environment variable on your host system, it will be automatically picked up by the Template. +You can find your Auth Token in the [LocalStack Web Application](https://app.localstack.cloud/workspace/auth-token). ### LocalStack - Docker-outside-of-Docker @@ -45,13 +46,14 @@ Or add additional services by modifying the provided `docker-compose.yml` file. For further LocalStack configuration options please consult our [official documentation](https://docs.localstack.cloud/references/configuration/). >[!WARNING] -> In this Template version however the LocalStack CLI provides the `start` and `stop` options do **NOT** control the LocalStack container with them as that would result in name resolution issues in the container. +> In this Template version LocalStack is managed by Docker Compose, lstk only talks to it via `AWS_ENDPOINT_URL` (set in `.env`). Lifecycle commands such as `lstk start` and `lstk stop` are therefore not available. > -> In case you've made this mistake by accident, try running `docker compose -f /docker-compose.yml up -d localstack` or rebuild the container. +> In case the LocalStack container is not running, try running `docker compose -f /docker-compose.yml up -d localstack` or rebuild the container. -#### Use LocalStack Pro +#### Auth Token -Set `usePro: true` and set on your host system the `LOCALSTACK_AUTH_TOKEN` or the `LOCALSTACK_API_KEY` environment variable, this will be automatically picked up by the `.env` file. +An Auth Token is required to start LocalStack. Set the `LOCALSTACK_AUTH_TOKEN` environment variable on your host system, it will be automatically picked up by the Template via the `.env` file. +You can find your Auth Token in the [LocalStack Web Application](https://app.localstack.cloud/workspace/auth-token). ## Repo and Template Structure @@ -63,14 +65,17 @@ This repository contains a _collection_ of two Templates - `localstack-dind` and │ │ ├── devcontainer-template.json │ │ ├── inputs.json │ │ └──| .devcontainer -│ │ └── devcontainer.json +│ │ ├── devcontainer.json +│ │ ├── install-lstk.sh +│ │ └── lstk.toml │ ├── localstack-dood │ │ ├── devcontainer-template.json │ │ └──| .devcontainer │ │ ├── .env │ │ ├── devcontainer.json │ │ ├── docker-compose.yaml -│ │ └── Dockerfile +│ │ ├── Dockerfile +│ │ └── install-lstk.sh | ├── ... │ │ ├── devcontainer-template.json │ │ └──| .devcontainer diff --git a/src/localstack-dind/.devcontainer/devcontainer.json b/src/localstack-dind/.devcontainer/devcontainer.json index 20013f7..4628f65 100644 --- a/src/localstack-dind/.devcontainer/devcontainer.json +++ b/src/localstack-dind/.devcontainer/devcontainer.json @@ -3,46 +3,33 @@ "image": "mcr.microsoft.com/devcontainers/base:${templateOption:imageVariant}", "remoteEnv": { - // Activate LocalStack Pro: https://docs.localstack.cloud/getting-started/auth-token/ - "LOCALSTACK_AUTH_TOKEN": "${localEnv:LOCALSTACK_AUTH_TOKEN}", // required for Pro, not processed via template due to security reasons - "LOCALSTACK_API_KEY": "${localEnv:LOCALSTACK_API_KEY}", - // LocalStack configuration: https://docs.localstack.cloud/references/configuration/ - "ACTIVATE_PRO": ${templateOption:usePro}, - "DEBUG": ${templateOption:debug}, - "LS_LOG": "${templateOption:logLevel}", - "PERSISTENCE": ${templateOption:persistence}, - "AWS_ENDPOINT_URL": "http://localhost.localstack.cloud:4566", - "AUTO_LOAD_POD": "${templateOption:loadPods}", - "ENFORCE_IAM": ${templateOption:enforceIam}, + // LocalStack Auth Token (required to start LocalStack): https://docs.localstack.cloud/aws/getting-started/auth-token/ + "LOCALSTACK_AUTH_TOKEN": "${localEnv:LOCALSTACK_AUTH_TOKEN}", // required, not processed via template due to security reasons "AWS_REGION": "${templateOption:defaultRegion}", - "AWS_DEFAULT_REGION": "${templateOption:defaultRegion}", - "IMAGE_NAME": "localstack/localstack-pro:${templateOption:version}", - "LOCALSTACK_VOLUME_DIR": "/data" + "AWS_DEFAULT_REGION": "${templateOption:defaultRegion}" + // LocalStack itself is configured in .devcontainer/lstk.toml }, // 👇 Features to add to the Dev Container. More info: https://containers.dev/implementors/features. "features": { - "ghcr.io/devcontainers/features/docker-in-docker:2": {}, - "ghcr.io/localstack/devcontainer-feature/localstack-cli:latest": { - "version": "${templateOption:version}", - "awslocal": ${templateOption:awslocal}, // if true, add in features manually: ghcr.io/devcontainers/features/aws-cli - "cdklocal": ${templateOption:cdklocal}, // if true, add in features manually: ghcr.io/devcontainers-contrib/features/aws-cdk - "pulumilocal": ${templateOption:pulumilocal}, // if true, add in features manually: ghcr.io/devcontainers-contrib/features/pulumi - "samlocal": ${templateOption:samlocal}, // if true, add in features manually: ghcr.io/customink/codespaces-features/sam-cli - "tflocal": ${templateOption:tflocal} // if true, add in features manually: ghcr.io/devcontainers-contrib/features/terraform-asdf - } + "ghcr.io/devcontainers/features/docker-in-docker:2": {} }, - // 👇 Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "type localstack; ${templateOption:startup} && localstack start -d || true", + // 👇 Install lstk, the LocalStack CLI: https://github.com/localstack/lstk + // lstk also proxies aws, terraform, cdk, sam and az commands to LocalStack. The wrapped tools are not installed, + // if needed add features manually, e.g. ghcr.io/devcontainers/features/aws-cli, ghcr.io/devcontainers/features/terraform + "onCreateCommand": "bash .devcontainer/install-lstk.sh .devcontainer/lstk.toml", + + // 👇 Start LocalStack once the Docker daemon (started in the background by the docker-in-docker feature) is ready + "postCreateCommand": "if ${templateOption:startup}; then timeout 120 sh -c 'until docker info > /dev/null 2>&1; do sleep 1; done' && lstk --non-interactive start --timeout 3m; fi", "mounts": [ { // to persist build data and images "source": "dind-var-lib-docker", "target": "/var/lib/docker", "type": "volume" - }, - { + }, + { "source": "${templateOption:volumePath}", "target": "/data", "type": "bind", diff --git a/src/localstack-dind/.devcontainer/install-lstk.sh b/src/localstack-dind/.devcontainer/install-lstk.sh new file mode 100755 index 0000000..4bdd675 --- /dev/null +++ b/src/localstack-dind/.devcontainer/install-lstk.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# Installs lstk, the LocalStack CLI: https://github.com/localstack/lstk +# Usage: install-lstk.sh [config.toml] +# config.toml optional lstk config, linked to ~/.config/lstk/config.toml so every lstk command uses it +# Set LSTK_VERSION (e.g. 1.5.0) to pin a release, defaults to the latest one. +set -euo pipefail + +CONFIG_FILE="${1:-}" +VERSION="${LSTK_VERSION:-latest}" +if [ "$VERSION" = "latest" ]; then + VERSION=$(curl -fsSLI -o /dev/null -w '%{url_effective}' https://github.com/localstack/lstk/releases/latest) + VERSION="${VERSION##*/}" +fi +VERSION="${VERSION#v}" + +case "$(uname -m)" in + x86_64|amd64) ARCH=amd64 ;; + aarch64|arm64) ARCH=arm64 ;; + *) echo "Unsupported architecture: $(uname -m)" >&2; exit 1 ;; +esac + +TMP_DIR=$(mktemp -d) +trap 'rm -rf "$TMP_DIR"' EXIT + +curl -fsSL "https://github.com/localstack/lstk/releases/download/v${VERSION}/lstk_${VERSION}_linux_${ARCH}.tar.gz" \ + | tar -xz -C "$TMP_DIR" + +SUDO="" +[ "$(id -u)" -ne 0 ] && SUDO="sudo" +# Keep the whole archive together: lstk finds its bundled extensions next to the +# symlink-resolved binary. +$SUDO rm -rf /usr/local/lib/lstk +$SUDO mkdir -p /usr/local/lib/lstk +$SUDO cp -R "$TMP_DIR"/. /usr/local/lib/lstk/ +$SUDO ln -sf /usr/local/lib/lstk/lstk /usr/local/bin/lstk + +if [ -n "$CONFIG_FILE" ]; then + mkdir -p "$HOME/.config/lstk" + ln -sf "$(realpath "$CONFIG_FILE")" "$HOME/.config/lstk/config.toml" +fi + +lstk --version diff --git a/src/localstack-dind/.devcontainer/lstk.toml b/src/localstack-dind/.devcontainer/lstk.toml new file mode 100644 index 0000000..3aac425 --- /dev/null +++ b/src/localstack-dind/.devcontainer/lstk.toml @@ -0,0 +1,18 @@ +# lstk configuration, linked to ~/.config/lstk/config.toml on container creation. +# Reference: https://docs.localstack.cloud/aws/developer-tools/running-localstack/lstk/configuration/ +[[containers]] +type = "aws" +tag = "${templateOption:version}" +port = "4566" +container_name = "localstack-main" +# Bind mounted from the host (see "mounts" in devcontainer.json) +volume = "/data" +env = ["devcontainer"] + +# LocalStack configuration passed to the container: https://docs.localstack.cloud/references/configuration/ +[env.devcontainer] +DEBUG = "${templateOption:debug}" +LS_LOG = "${templateOption:logLevel}" +PERSISTENCE = "${templateOption:persistence}" +ENFORCE_IAM = "${templateOption:enforceIam}" +AUTO_LOAD_POD = "${templateOption:loadPods}" diff --git a/src/localstack-dind/NOTES.md b/src/localstack-dind/NOTES.md index ef1287e..a290e02 100644 --- a/src/localstack-dind/NOTES.md +++ b/src/localstack-dind/NOTES.md @@ -1,13 +1,14 @@ This version of the Template starts up LocalStack in an internal Docker service in the DevContainer, hence we set a volume by default for data persistence. As a result the newly built DevContainers do not necessarily need to re-download images as long this volume exists on the system. -Additionally the DevContainer bind mounts a folder from the host system as `/data`, which will be used to store LocalStack data (`LOCALSTACK_VOLUME_DIR`). +Additionally the DevContainer bind mounts a folder from the host system as `/data`, which will be used to store LocalStack data. -The Template adds automatically the [official LocalStack DevContainer Feature](https://github.com/localstack/devcontainer-feature), which installs the CLI and by demand the most popular *Local Tools™*. -Currently this calls for a **Debian-based** DevContainer image. +The Template installs [lstk](https://github.com/localstack/lstk), the LocalStack CLI. Besides managing LocalStack, lstk proxies `aws`, `terraform`, `cdk`, `sam` and `az` commands to LocalStack (e.g. `lstk aws s3 ls`). The wrapped tools themselves need to be added separately, e.g. via the `ghcr.io/devcontainers/features/aws-cli` Feature. -LocalStack in this variation is controlled via the LocalStack CLI and some env variables that you can adjust or expand in the `devcontainer.json` file's `remoteEnv` block. +LocalStack in this variation is started with `lstk start` after the DevContainer is created and is controlled with lstk (`lstk status`, `lstk stop`, `lstk logs`, ...). +The image version and the LocalStack configuration live in `.devcontainer/lstk.toml`, which is linked as the lstk config (`~/.config/lstk/config.toml`); add further LocalStack variables to its `[env.devcontainer]` section. For further LocalStack configuration options please consult our [official documentation](https://docs.localstack.cloud/references/configuration/). -## Use LocalStack Pro +## Auth Token -Set `usePro: true` and set on your host system the `LOCALSTACK_AUTH_TOKEN` or the `LOCALSTACK_API_KEY` environment variable, this will be automatically picked up by the Template. \ No newline at end of file +An Auth Token is required to start LocalStack. Set the `LOCALSTACK_AUTH_TOKEN` environment variable on your host system, it will be automatically picked up by the Template. +You can find your Auth Token in the [LocalStack Web Application](https://app.localstack.cloud/workspace/auth-token). \ No newline at end of file diff --git a/src/localstack-dind/README.md b/src/localstack-dind/README.md index 9a476c0..3e0eab2 100644 --- a/src/localstack-dind/README.md +++ b/src/localstack-dind/README.md @@ -8,35 +8,30 @@ A template to manage LocalStack in DinD via CLI | Options Id | Description | Type | Default Value | |-----|-----|-----|-----| | imageVariant | Debian version (use bullseye or jammy on local arm64/Apple Silicon): | string | jammy | -| awslocal | Install LocalStack wrapper for AWS CLI: | boolean | false | -| cdklocal | Install LocalStack wrapper for CDK: | boolean | false | -| pulumilocal | Install LocalStack wrapper for Pulumi: | boolean | false | -| samlocal | Install LocalStack wrapper for AWS SAM CLI: | boolean | false | -| tflocal | Install LocalStack wrapper for Terraform: | boolean | false | | logLevel | Set LocalStack log level: | string | info | -| debug | - | boolean | false | -| persistence | - | boolean | false | -| usePro | - | boolean | false | -| version | - | string | latest | -| loadPods | - | string | | -| volumePath | - | string | ./.volume | -| enforceIam | - | boolean | false | -| defaultRegion | - | string | us-east-1 | +| debug | Enable LocalStack debugging: | boolean | false | +| persistence | Enable persistence in LocalStack: | boolean | false | +| version | LocalStack image version: | string | latest | +| loadPods | Load Cloud Pods at start-up (comma-separated list): | string | | +| volumePath | LocalStack volume location on the host (currently only local (bind) mounts recommended): | string | ./.volume | +| enforceIam | Enforce IAM: | boolean | false | +| defaultRegion | Default AWS region: | string | us-east-1 | | startup | Start up LocalStack: | boolean | true | This version of the Template starts up LocalStack in an internal Docker service in the DevContainer, hence we set a volume by default for data persistence. As a result the newly built DevContainers do not necessarily need to re-download images as long this volume exists on the system. -Additionally the DevContainer bind mounts a folder from the host system as `/data`, which will be used to store LocalStack data (`LOCALSTACK_VOLUME_DIR`). +Additionally the DevContainer bind mounts a folder from the host system as `/data`, which will be used to store LocalStack data. -The Template adds automatically the [official LocalStack DevContainer Feature](https://github.com/localstack/devcontainer-feature), which installs the CLI and by demand the most popular *Local Tools™*. -Currently this calls for a **Debian-based** DevContainer image. +The Template installs [lstk](https://github.com/localstack/lstk), the LocalStack CLI. Besides managing LocalStack, lstk proxies `aws`, `terraform`, `cdk`, `sam` and `az` commands to LocalStack (e.g. `lstk aws s3 ls`). The wrapped tools themselves need to be added separately, e.g. via the `ghcr.io/devcontainers/features/aws-cli` Feature. -LocalStack in this variation is controlled via the LocalStack CLI and some env variables that you can adjust or expand in the `devcontainer.json` file's `remoteEnv` block. +LocalStack in this variation is started with `lstk start` after the DevContainer is created and is controlled with lstk (`lstk status`, `lstk stop`, `lstk logs`, ...). +The image version and the LocalStack configuration live in `.devcontainer/lstk.toml`, which is linked as the lstk config (`~/.config/lstk/config.toml`); add further LocalStack variables to its `[env.devcontainer]` section. For further LocalStack configuration options please consult our [official documentation](https://docs.localstack.cloud/references/configuration/). -## Use LocalStack Pro +## Auth Token -Set `usePro: true` and set on your host system the `LOCALSTACK_AUTH_TOKEN` or the `LOCALSTACK_API_KEY` environment variable, this will be automatically picked up by the Template. +An Auth Token is required to start LocalStack. Set the `LOCALSTACK_AUTH_TOKEN` environment variable on your host system, it will be automatically picked up by the Template. +You can find your Auth Token in the [LocalStack Web Application](https://app.localstack.cloud/workspace/auth-token). --- diff --git a/src/localstack-dind/devcontainer-template.json b/src/localstack-dind/devcontainer-template.json index 7915a54..2591912 100644 --- a/src/localstack-dind/devcontainer-template.json +++ b/src/localstack-dind/devcontainer-template.json @@ -17,31 +17,6 @@ ], "default": "jammy" }, - "awslocal": { - "type": "boolean", - "description": "Install LocalStack wrapper for AWS CLI:", - "default": "false" - }, - "cdklocal": { - "type": "boolean", - "description": "Install LocalStack wrapper for CDK:", - "default": "false" - }, - "pulumilocal": { - "type": "boolean", - "description": "Install LocalStack wrapper for Pulumi:", - "default": "false" - }, - "samlocal": { - "type": "boolean", - "description": "Install LocalStack wrapper for AWS SAM CLI:", - "default": "false" - }, - "tflocal": { - "type": "boolean", - "description": "Install LocalStack wrapper for Terraform:", - "default": "false" - }, "logLevel": { "type": "string", "description": "Set LocalStack log level:", @@ -58,53 +33,49 @@ }, "debug": { "type": "boolean", - "descripiton": "Enable LocalStack debugging:", + "description": "Enable LocalStack debugging:", "default": "false" }, "persistence": { "type": "boolean", - "descripiton": "Enable persistence in LocalStack:", - "default": "false" - }, - "usePro": { - "type": "boolean", - "descripiton": "Enable LocalStack Pro:", + "description": "Enable persistence in LocalStack:", "default": "false" }, "version": { "type": "string", - "descripiton": "Use LocalStack version:", + "description": "LocalStack image version:", "proposals": [ "latest", - "3.6.0", - "3.5.0", - "3.4.0", - "3.3.0", - "3.2.0", - "3.1.0", - "3.0.2", - "3.0.1" + "2026.10.8", + "2026.9.1", + "2026.8.5", + "2026.7.6", + "2026.6.4", + "2026.5.4", + "2026.4.3", + "2026.3.0", + "4.14.0" ], "default": "latest" }, "loadPods": { "type": "string", - "descripiton": "Load Cloud Pods at start-up (comma-separated list):", + "description": "Load Cloud Pods at start-up (comma-separated list):", "default": " " }, "volumePath": { "type": "string", - "descripiton": "LocalStack volume location on the host (currently only local (bind) mounts recommended):", + "description": "LocalStack volume location on the host (currently only local (bind) mounts recommended):", "default": "./.volume" }, "enforceIam": { "type": "boolean", - "descripiton": "Enforce IAM:", + "description": "Enforce IAM:", "default": "false" }, "defaultRegion": { "type": "string", - "descripiton": "Default AWS region:", + "description": "Default AWS region:", "proposals": [ "us-east-1", "us-east-2", diff --git a/src/localstack-dood/.devcontainer/.env b/src/localstack-dood/.devcontainer/.env index 7cc063e..2efb16e 100644 --- a/src/localstack-dood/.devcontainer/.env +++ b/src/localstack-dood/.devcontainer/.env @@ -1,8 +1,7 @@ -# Activate LocalStack Pro: https://docs.localstack.cloud/getting-started/auth-token/ -LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN:-} # required for Pro, not processed via template due to security reasons +# LocalStack Auth Token (required to start LocalStack): https://docs.localstack.cloud/aws/getting-started/auth-token/ +LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN:-} # required, not processed via template due to security reasons LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY:-} # LocalStack configuration: https://docs.localstack.cloud/references/configuration/ -ACTIVATE_PRO=${templateOption:usePro} DEBUG=${templateOption:debug} LS_LOG=${templateOption:logLevel} PERSISTENCE=${templateOption:persistence} @@ -12,4 +11,3 @@ AUTO_LOAD_POD=${templateOption:loadPods} ENFORCE_IAM=${templateOption:enforceIam} AWS_REGION=${templateOption:defaultRegion} AWS_DEFAULT_REGION=${templateOption:defaultRegion} -IMAGE_NAME=localstack/localstack-pro:${templateOption:version} \ No newline at end of file diff --git a/src/localstack-dood/.devcontainer/Dockerfile b/src/localstack-dood/.devcontainer/Dockerfile index 550a29a..41dbb4f 100644 --- a/src/localstack-dood/.devcontainer/Dockerfile +++ b/src/localstack-dood/.devcontainer/Dockerfile @@ -1 +1,6 @@ FROM mcr.microsoft.com/devcontainers/base:${templateOption:imageVariant} + +# Install lstk, the LocalStack CLI: https://github.com/localstack/lstk +# Done at build time, as at runtime the container resolves DNS through the LocalStack container (see docker-compose.yml) +COPY install-lstk.sh /tmp/install-lstk.sh +RUN bash /tmp/install-lstk.sh && rm /tmp/install-lstk.sh diff --git a/src/localstack-dood/.devcontainer/devcontainer.json b/src/localstack-dood/.devcontainer/devcontainer.json index e0b6bca..369d743 100644 --- a/src/localstack-dood/.devcontainer/devcontainer.json +++ b/src/localstack-dood/.devcontainer/devcontainer.json @@ -6,14 +6,10 @@ // 👇 Features to add to the Dev Container. More info: https://containers.dev/implementors/features. "features": { - "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}, - "ghcr.io/localstack/devcontainer-feature/localstack-cli:latest": { - "version": "${templateOption:version}", - "awslocal": ${templateOption:awslocal}, // if true, add in features manually: ghcr.io/devcontainers/features/aws-cli - "cdklocal": ${templateOption:cdklocal}, // if true, add in features manually: ghcr.io/devcontainers-contrib/features/aws-cdk - "pulumilocal": ${templateOption:pulumilocal}, // if true, add in features manually: ghcr.io/devcontainers-contrib/features/pulumi - "samlocal": ${templateOption:samlocal}, // if true, add in features manually: ghcr.io/customink/codespaces-features/sam-cli - "tflocal": ${templateOption:tflocal} // if true, add in features manually: ghcr.io/devcontainers-contrib/features/terraform-asdf - } + "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {} } + + // lstk, the LocalStack CLI (https://github.com/localstack/lstk), is installed in the Dockerfile. It talks to the LocalStack + // container from docker-compose.yml via AWS_ENDPOINT_URL (set in .env) and proxies aws, terraform, cdk, sam and az commands to it. + // The wrapped tools are not installed, if needed add features manually, e.g. ghcr.io/devcontainers/features/aws-cli } diff --git a/src/localstack-dood/.devcontainer/docker-compose.yml b/src/localstack-dood/.devcontainer/docker-compose.yml index cb4d8c5..68ccf59 100644 --- a/src/localstack-dood/.devcontainer/docker-compose.yml +++ b/src/localstack-dood/.devcontainer/docker-compose.yml @@ -3,7 +3,7 @@ version: "3.8" services: localstack: container_name: "localstack-main" - image: localstack/localstack-pro:${templateOption:version} # required for Pro + image: localstack/localstack-pro:${templateOption:version} ports: - "127.0.0.1:4566:4566" # LocalStack Gateway - "127.0.0.1:4510-4559:4510-4559" # external services port range diff --git a/src/localstack-dood/.devcontainer/install-lstk.sh b/src/localstack-dood/.devcontainer/install-lstk.sh new file mode 100755 index 0000000..4bdd675 --- /dev/null +++ b/src/localstack-dood/.devcontainer/install-lstk.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# Installs lstk, the LocalStack CLI: https://github.com/localstack/lstk +# Usage: install-lstk.sh [config.toml] +# config.toml optional lstk config, linked to ~/.config/lstk/config.toml so every lstk command uses it +# Set LSTK_VERSION (e.g. 1.5.0) to pin a release, defaults to the latest one. +set -euo pipefail + +CONFIG_FILE="${1:-}" +VERSION="${LSTK_VERSION:-latest}" +if [ "$VERSION" = "latest" ]; then + VERSION=$(curl -fsSLI -o /dev/null -w '%{url_effective}' https://github.com/localstack/lstk/releases/latest) + VERSION="${VERSION##*/}" +fi +VERSION="${VERSION#v}" + +case "$(uname -m)" in + x86_64|amd64) ARCH=amd64 ;; + aarch64|arm64) ARCH=arm64 ;; + *) echo "Unsupported architecture: $(uname -m)" >&2; exit 1 ;; +esac + +TMP_DIR=$(mktemp -d) +trap 'rm -rf "$TMP_DIR"' EXIT + +curl -fsSL "https://github.com/localstack/lstk/releases/download/v${VERSION}/lstk_${VERSION}_linux_${ARCH}.tar.gz" \ + | tar -xz -C "$TMP_DIR" + +SUDO="" +[ "$(id -u)" -ne 0 ] && SUDO="sudo" +# Keep the whole archive together: lstk finds its bundled extensions next to the +# symlink-resolved binary. +$SUDO rm -rf /usr/local/lib/lstk +$SUDO mkdir -p /usr/local/lib/lstk +$SUDO cp -R "$TMP_DIR"/. /usr/local/lib/lstk/ +$SUDO ln -sf /usr/local/lib/lstk/lstk /usr/local/bin/lstk + +if [ -n "$CONFIG_FILE" ]; then + mkdir -p "$HOME/.config/lstk" + ln -sf "$(realpath "$CONFIG_FILE")" "$HOME/.config/lstk/config.toml" +fi + +lstk --version diff --git a/src/localstack-dood/NOTES.md b/src/localstack-dood/NOTES.md index a9da843..bebc8f9 100644 --- a/src/localstack-dood/NOTES.md +++ b/src/localstack-dood/NOTES.md @@ -5,14 +5,14 @@ For further customisation you can edit the provided `Dockerfile` and/or the `dev Or add additional services by modifying the provided `docker-compose.yml` file. For further LocalStack configuration options please consult our [official documentation](https://docs.localstack.cloud/references/configuration/). -The Template adds automatically the [official LocalStack DevContainer Feature](https://github.com/localstack/devcontainer-feature), which installs the CLI and by demand the most popular *Local Tools™*. -Currently this calls for a **Debian-based** DevContainer image. +The Template installs [lstk](https://github.com/localstack/lstk), the LocalStack CLI. Besides managing LocalStack, lstk proxies `aws`, `terraform`, `cdk`, `sam` and `az` commands to LocalStack (e.g. `lstk aws s3 ls`). The wrapped tools themselves need to be added separately, e.g. via the `ghcr.io/devcontainers/features/aws-cli` Feature. >[!WARNING] -> In this Template version however the LocalStack CLI provides the `start` and `stop` options do not control the LocalStack container with them as that would result in name resolution issues with the container. +> In this Template version LocalStack is managed by Docker Compose, lstk only talks to it via `AWS_ENDPOINT_URL` (set in `.env`). Lifecycle commands such as `lstk start` and `lstk stop` are therefore not available. > -> In case you've made this mistake by accident, try running `docker compose -f /docker-compose.yml up -d localstack` or rebuild the container. +> In case the LocalStack container is not running, try running `docker compose -f /docker-compose.yml up -d localstack` or rebuild the container. -#### Use LocalStack Pro +#### Auth Token -Set `usePro: true` and set on your host system the `LOCALSTACK_AUTH_TOKEN` or the `LOCALSTACK_API_KEY` environment variable, this will be automatically picked up by the `.env` file. \ No newline at end of file +An Auth Token is required to start LocalStack. Set the `LOCALSTACK_AUTH_TOKEN` environment variable on your host system, it will be automatically picked up by the Template via the `.env` file. +You can find your Auth Token in the [LocalStack Web Application](https://app.localstack.cloud/workspace/auth-token). \ No newline at end of file diff --git a/src/localstack-dood/README.md b/src/localstack-dood/README.md index ad23591..502c9c9 100644 --- a/src/localstack-dood/README.md +++ b/src/localstack-dood/README.md @@ -8,24 +8,18 @@ A template to manage LocalStack in DooD | Options Id | Description | Type | Default Value | |-----|-----|-----|-----| | imageVariant | Debian version (use bullseye or jammy on local arm64/Apple Silicon): | string | jammy | -| awslocal | Install LocalStack wrapper for AWS CLI: | boolean | false | -| cdklocal | Install LocalStack wrapper for CDK: | boolean | false | -| pulumilocal | Install LocalStack wrapper for Pulumi: | boolean | false | -| samlocal | Install LocalStack wrapper for AWS SAM CLI: | boolean | false | -| tflocal | Install LocalStack wrapper for Terraform: | boolean | false | | logLevel | Set LocalStack log level: | string | info | -| networkName | - | string | ls | -| networkCidr | - | string | 10.0.2.0/24 | -| ipAddress | - | string | 10.0.2.20 | -| host | - | string | localhost.localstack.cloud:4566 | -| debug | - | boolean | false | -| persistence | - | boolean | false | -| usePro | - | boolean | false | -| version | - | string | latest | -| loadPods | - | string | | -| volumePath | - | string | ./.volume | -| enforceIam | - | boolean | false | -| defaultRegion | - | string | us-east-1 | +| networkName | LocalStack network name: | string | ls | +| networkCidr | LocalStack network CIDR: | string | 10.0.2.0/24 | +| ipAddress | LocalStack IP: | string | 10.0.2.20 | +| host | LocalStack hostname: | string | localhost.localstack.cloud:4566 | +| debug | Enable LocalStack debugging: | boolean | false | +| persistence | Enable persistence in LocalStack: | boolean | false | +| version | LocalStack image version: | string | latest | +| loadPods | Load Cloud Pods at start-up (comma-separated list): | string | | +| volumePath | LocalStack volume location on the host (currently only local (bind) mounts recommended): | string | ./.volume | +| enforceIam | Enforce IAM: | boolean | false | +| defaultRegion | Default AWS region: | string | us-east-1 | This version of the Template starts up LocalStack as a separate container in the same Docker network using the host system's Docker socket. @@ -34,17 +28,17 @@ For further customisation you can edit the provided `Dockerfile` and/or the `dev Or add additional services by modifying the provided `docker-compose.yml` file. For further LocalStack configuration options please consult our [official documentation](https://docs.localstack.cloud/references/configuration/). -The Template adds automatically the [official LocalStack DevContainer Feature](https://github.com/localstack/devcontainer-feature), which installs the CLI and by demand the most popular *Local Tools™*. -Currently this calls for a **Debian-based** DevContainer image. +The Template installs [lstk](https://github.com/localstack/lstk), the LocalStack CLI. Besides managing LocalStack, lstk proxies `aws`, `terraform`, `cdk`, `sam` and `az` commands to LocalStack (e.g. `lstk aws s3 ls`). The wrapped tools themselves need to be added separately, e.g. via the `ghcr.io/devcontainers/features/aws-cli` Feature. >[!WARNING] -> In this Template version however the LocalStack CLI provides the `start` and `stop` options do not control the LocalStack container with them as that would result in name resolution issues with the container. +> In this Template version LocalStack is managed by Docker Compose, lstk only talks to it via `AWS_ENDPOINT_URL` (set in `.env`). Lifecycle commands such as `lstk start` and `lstk stop` are therefore not available. > -> In case you've made this mistake by accident, try running `docker compose -f /docker-compose.yml up -d localstack` or rebuild the container. +> In case the LocalStack container is not running, try running `docker compose -f /docker-compose.yml up -d localstack` or rebuild the container. -#### Use LocalStack Pro +#### Auth Token -Set `usePro: true` and set on your host system the `LOCALSTACK_AUTH_TOKEN` or the `LOCALSTACK_API_KEY` environment variable, this will be automatically picked up by the `.env` file. +An Auth Token is required to start LocalStack. Set the `LOCALSTACK_AUTH_TOKEN` environment variable on your host system, it will be automatically picked up by the Template via the `.env` file. +You can find your Auth Token in the [LocalStack Web Application](https://app.localstack.cloud/workspace/auth-token). --- diff --git a/src/localstack-dood/devcontainer-template.json b/src/localstack-dood/devcontainer-template.json index 4037beb..cc61865 100644 --- a/src/localstack-dood/devcontainer-template.json +++ b/src/localstack-dood/devcontainer-template.json @@ -17,31 +17,6 @@ ], "default": "jammy" }, - "awslocal": { - "type": "boolean", - "description": "Install LocalStack wrapper for AWS CLI:", - "default": "false" - }, - "cdklocal": { - "type": "boolean", - "description": "Install LocalStack wrapper for CDK:", - "default": "false" - }, - "pulumilocal": { - "type": "boolean", - "description": "Install LocalStack wrapper for Pulumi:", - "default": "false" - }, - "samlocal": { - "type": "boolean", - "description": "Install LocalStack wrapper for AWS SAM CLI:", - "default": "false" - }, - "tflocal": { - "type": "boolean", - "description": "Install LocalStack wrapper for Terraform:", - "default": "false" - }, "logLevel": { "type": "string", "description": "Set LocalStack log level:", @@ -58,22 +33,22 @@ }, "networkName": { "type": "string", - "descripiton": "LocalStack network name:", + "description": "LocalStack network name:", "default": "ls" }, "networkCidr": { "type": "string", - "descripiton": "LocalStack network CIDR:", + "description": "LocalStack network CIDR:", "default": "10.0.2.0/24" }, "ipAddress": { "type": "string", - "descripiton": "LocalStack IP:", + "description": "LocalStack IP:", "default": "10.0.2.20" }, "host": { "type": "string", - "descripiton": "LocalStack hostname:", + "description": "LocalStack hostname:", "proposals": [ "localhost.localstack.cloud:4566" ], @@ -81,53 +56,49 @@ }, "debug": { "type": "boolean", - "descripiton": "Enable LocalStack debugging:", + "description": "Enable LocalStack debugging:", "default": "false" }, "persistence": { "type": "boolean", - "descripiton": "Enable persistence in LocalStack:", - "default": "false" - }, - "usePro": { - "type": "boolean", - "descripiton": "Enable LocalStack Pro:", + "description": "Enable persistence in LocalStack:", "default": "false" }, "version": { "type": "string", - "descripiton": "Use LocalStack version:", + "description": "LocalStack image version:", "proposals": [ "latest", - "3.6.0", - "3.5.0", - "3.4.0", - "3.3.0", - "3.2.0", - "3.1.0", - "3.0.2", - "3.0.1" + "2026.10.8", + "2026.9.1", + "2026.8.5", + "2026.7.6", + "2026.6.4", + "2026.5.4", + "2026.4.3", + "2026.3.0", + "4.14.0" ], "default": "latest" }, "loadPods": { "type": "string", - "descripiton": "Load Cloud Pods at start-up (comma-separated list):", + "description": "Load Cloud Pods at start-up (comma-separated list):", "default": " " }, "volumePath": { "type": "string", - "descripiton": "LocalStack volume location on the host (currently only local (bind) mounts recommended):", + "description": "LocalStack volume location on the host (currently only local (bind) mounts recommended):", "default": "./.volume" }, "enforceIam": { "type": "boolean", - "descripiton": "Enforce IAM:", + "description": "Enforce IAM:", "default": "false" }, "defaultRegion": { "type": "string", - "descripiton": "Default AWS region:", + "description": "Default AWS region:", "proposals": [ "us-east-1", "us-east-2", diff --git a/test/localstack-dind/custom_region_with_iam_enforce.sh b/test/localstack-dind/custom_region_with_iam_enforce.sh index 7f1c31a..7df8466 100644 --- a/test/localstack-dind/custom_region_with_iam_enforce.sh +++ b/test/localstack-dind/custom_region_with_iam_enforce.sh @@ -2,14 +2,14 @@ cd $(dirname "$0") source test-utils.sh -localstack wait -t 30 +waitForLocalStack # Scenario specific tests -check "localstack version" localstack --version -check "default region" awslocal sqs create-queue --queue-name test-queue | grep eu-central-1 +check "lstk version" lstk --version +check "default region" 'lstk aws sqs create-queue --queue-name test-queue | grep eu-central-1' -awslocal iam create-user --user-name test -awslocal iam put-user-policy --user-name test --policy-name restrict-queue-list --policy-document "$(cat < /dev/null -localstack wait -t 30 +check "distro" 'lsb_release -c | grep bookworm' +waitForLocalStack +check "localstack running" lstk --non-interactive status check "debug enabled" "curl -s http://localhost:4566/_localstack/diagnose; echo" check "debug enabled" "curl -s http://localhost:4566/_localstack/diagnose | jq -r '.config.LS_LOG' | grep trace" diff --git a/test/localstack-dind/persistence_custom_volume_with_2026_9.sh b/test/localstack-dind/persistence_custom_volume_with_2026_9.sh new file mode 100644 index 0000000..967dfd3 --- /dev/null +++ b/test/localstack-dind/persistence_custom_volume_with_2026_9.sh @@ -0,0 +1,18 @@ +#!/bin/bash +cd $(dirname "$0") +source test-utils.sh + +waitForLocalStack + +# Scenario specific tests +check "localstack image version" "curl -s http://localhost:4566/_localstack/health | jq -e '.version | startswith(\"2026.9.\")'" +check "persist localstack data" "docker inspect localstack-main | jq -e '.[0].Config.Env | index(\"PERSISTENCE=true\") != null'" + +lstk aws s3 mb s3://devcontainer-persisted-data +lstk --non-interactive stop && lstk --non-interactive start --timeout 3m +waitForLocalStack + +check "data persisted" "lstk aws s3api list-buckets | jq -e '.Buckets | any(.Name == \"devcontainer-persisted-data\")'" + +# Report result +reportResults diff --git a/test/localstack-dind/persistence_custom_volume_with_3_3_0.sh b/test/localstack-dind/persistence_custom_volume_with_3_3_0.sh deleted file mode 100644 index 4e3b896..0000000 --- a/test/localstack-dind/persistence_custom_volume_with_3_3_0.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -cd $(dirname "$0") -source test-utils.sh - -localstack wait -t 30 - -# Scenario specific tests -check "localstack-cli version" 'localstack --version | grep 3.3.0' -check "localstack image version" 'localstack status | grep "Docker image" | grep 3.3.0' -check "persist localstack data" "localstack config show | grep -w PERSISTENCE | grep -io True" - -awslocal s3 mb s3://devcontainer-persisted-data -localstack stop && localstack start -d -localstack wait -t 30 - -check "data persisted" "awslocal s3api list-buckets | jq -e '.Buckets | any(.Name == \"devcontainer-persisted-data\")' " - -# Report result -reportResults diff --git a/test/localstack-dind/scenarios.json b/test/localstack-dind/scenarios.json index 727bb01..b0ca2fa 100644 --- a/test/localstack-dind/scenarios.json +++ b/test/localstack-dind/scenarios.json @@ -1,14 +1,6 @@ { "tools_no_startup": { - "features": { - "ghcr.io/devcontainers/features/node:1": {} - }, "imageVariant": "jammy", - "awslocal": true, - "cdklocal": true, - "pulumilocal": true, - "samlocal": true, - "tflocal": true, "startup": false }, "debug_mode_on_bookworm": { @@ -20,28 +12,21 @@ "features": { "ghcr.io/devcontainers/features/aws-cli:1": {} }, - "usePro": true, - "awslocal": true, - "loadPods": "devcontainer-use_pro_and_pod", - "version": "3.5.0" + "loadPods": "devcontainer-use_pro_and_pod" }, - "persistence_custom_volume_with_3_3_0": { + "persistence_custom_volume_with_2026_9": { "features": { "ghcr.io/devcontainers/features/aws-cli:1": {} }, - "usePro": true, - "awslocal": true, - "version": "3.3.0", + "version": "2026.9.1", "persistence": true, "volumePath": "./volume" }, "custom_region_with_iam_enforce": { - "awslocal": true, "features": { "ghcr.io/devcontainers/features/aws-cli:1": {} }, "defaultRegion": "eu-central-1", - "enforceIam": true, - "usePro": true + "enforceIam": true } } \ No newline at end of file diff --git a/test/localstack-dind/test.sh b/test/localstack-dind/test.sh index 969aa4d..7420810 100644 --- a/test/localstack-dind/test.sh +++ b/test/localstack-dind/test.sh @@ -3,9 +3,9 @@ cd $(dirname "$0") source test-utils.sh # Template specific tests -check "distro" lsb_release -c | grep "jammy" -check "localstack status" localstack status -check "localstack stops" localstack stop +check "distro" 'lsb_release -c | grep jammy' +check "localstack status" lstk --non-interactive status +check "localstack stops" lstk --non-interactive stop # Report result reportResults diff --git a/test/localstack-dind/tools_no_startup.sh b/test/localstack-dind/tools_no_startup.sh index d75d766..8a36513 100644 --- a/test/localstack-dind/tools_no_startup.sh +++ b/test/localstack-dind/tools_no_startup.sh @@ -3,13 +3,9 @@ cd $(dirname "$0") source test-utils.sh # Scenario specific tests -check "distro" lsb_release -c | grep "jammy" -check "awslocal" type awslocal -check "cdklocal" type cdklocal -check "pulumilocal" type pulumilocal -check "samlocal" type samlocal -check "tflocal" type tflocal -check "localstack stopped" localstack status; localstack status | grep stopped > /dev/null +check "distro" 'lsb_release -c | grep jammy' +check "lstk" type lstk +check "localstack stopped" "! lstk --non-interactive status" # Report result reportResults diff --git a/test/localstack-dind/use_pro_and_pod.sh b/test/localstack-dind/use_pro_and_pod.sh index 5e31c12..6b6f07e 100644 --- a/test/localstack-dind/use_pro_and_pod.sh +++ b/test/localstack-dind/use_pro_and_pod.sh @@ -3,13 +3,9 @@ cd $(dirname "$0") source test-utils.sh # Scenario specific tests -check "localstack-cli version" 'localstack --version | grep 3.5.0' -check "localstack image version" 'localstack status | grep "Docker image" | grep 3.5.0' -check "localstack is pro" "docker inspect localstack-main | jq -e '.[0].Config.Env | index(\"ACTIVATE_PRO=1\") != null'" - -localstack wait -t 30 +waitForLocalStack SCENARIO=$(basename -s .sh $0) -check "pod loaded resources" "awslocal s3api list-buckets | jq -e '.Buckets | any(.Name == \"devcontainer-test\")'" +check "pod loaded resources" "lstk aws s3api list-buckets | jq -e '.Buckets | any(.Name == \"devcontainer-test\")'" # Report result reportResults diff --git a/test/localstack-dood/custom_region_with_iam_enforce.sh b/test/localstack-dood/custom_region_with_iam_enforce.sh index a6bfc70..0fe3d5c 100644 --- a/test/localstack-dood/custom_region_with_iam_enforce.sh +++ b/test/localstack-dood/custom_region_with_iam_enforce.sh @@ -2,14 +2,14 @@ cd $(dirname "$0") source test-utils.sh -localstack wait -t 30 +waitForLocalStack # Scenario specific tests -check "localstack status" localstack status -check "default region" awslocal sqs create-queue --queue-name test-queue | grep eu-central-1 +check "localstack status" lstk --non-interactive status +check "default region" 'lstk aws sqs create-queue --queue-name test-queue | grep eu-central-1' -awslocal iam create-user --user-name test -awslocal iam put-user-policy --user-name test --policy-name restrict-queue-list --policy-document "$(cat < /dev/null -localstack wait -t 30 +check "distro" 'lsb_release -c | grep bookworm' +waitForLocalStack +check "localstack running" lstk --non-interactive status check "debug enabled" "curl -s http://localhost.localstack.cloud:4566/_localstack/diagnose; echo" check "log level is trace" "curl -s http://localhost.localstack.cloud:4566/_localstack/diagnose | jq -r '.config.LS_LOG'" diff --git a/test/localstack-dood/scenarios.json b/test/localstack-dood/scenarios.json index aad9150..3328dae 100644 --- a/test/localstack-dood/scenarios.json +++ b/test/localstack-dood/scenarios.json @@ -1,14 +1,6 @@ { "tools": { - "features": { - "ghcr.io/devcontainers/features/node:1": {} - }, "imageVariant": "jammy", - "awslocal": true, - "cdklocal": true, - "pulumilocal": true, - "samlocal": true, - "tflocal": true, "startup": false }, "debug_mode_on_bookworm": { @@ -20,28 +12,21 @@ "features": { "ghcr.io/devcontainers/features/aws-cli:1": {} }, - "usePro": true, - "awslocal": true, - "loadPods": "devcontainer-use_pro_and_pod", - "version": "3.5.0" + "loadPods": "devcontainer-use_pro_and_pod" }, - "custom_volume_and_host_with_3_3_0": { + "custom_volume_and_host_with_2026_9": { "features": { "ghcr.io/devcontainers/features/aws-cli:1": {} }, - "usePro": true, - "awslocal": true, - "version": "3.3.0", + "version": "2026.9.1", "volumePath": "./volume", "host": "my-host.localstack.cloud:4566" }, "custom_region_with_iam_enforce": { - "awslocal": true, "features": { "ghcr.io/devcontainers/features/aws-cli:1": {} }, "defaultRegion": "eu-central-1", - "enforceIam": true, - "usePro": true + "enforceIam": true } } \ No newline at end of file diff --git a/test/localstack-dood/test.sh b/test/localstack-dood/test.sh index 969aa4d..933880a 100644 --- a/test/localstack-dood/test.sh +++ b/test/localstack-dood/test.sh @@ -3,9 +3,8 @@ cd $(dirname "$0") source test-utils.sh # Template specific tests -check "distro" lsb_release -c | grep "jammy" -check "localstack status" localstack status -check "localstack stops" localstack stop +check "distro" 'lsb_release -c | grep jammy' +check "localstack status" lstk --non-interactive status # Report result reportResults diff --git a/test/localstack-dood/tools.sh b/test/localstack-dood/tools.sh index 77505a4..9bee55a 100644 --- a/test/localstack-dood/tools.sh +++ b/test/localstack-dood/tools.sh @@ -3,12 +3,8 @@ cd $(dirname "$0") source test-utils.sh # Scenario specific tests -check "distro" lsb_release -c | grep "jammy" -check "awslocal" type awslocal -check "cdklocal" type cdklocal -check "pulumilocal" type pulumilocal -check "samlocal" type samlocal -check "tflocal" type tflocal +check "distro" 'lsb_release -c | grep jammy' +check "lstk" type lstk # Report result reportResults diff --git a/test/localstack-dood/use_pro_and_pod.sh b/test/localstack-dood/use_pro_and_pod.sh index f99eafd..c29bd11 100644 --- a/test/localstack-dood/use_pro_and_pod.sh +++ b/test/localstack-dood/use_pro_and_pod.sh @@ -2,14 +2,11 @@ cd $(dirname "$0") source test-utils.sh -# Scenario specific tests -check "localstack-cli version" 'localstack --version | grep 3.5.0' -check "localstack image version" 'localstack status | grep "Docker image" | grep 3.5.0' -check "localstack is pro" "docker inspect localstack-main | jq -e '.[0].Config.Env | index(\"ACTIVATE_PRO=true\") != null'" - -localstack wait -t 30 +waitForLocalStack SCENARIO=$(basename -s .sh $0) -check "pod loaded resources" "awslocal s3api list-buckets | jq -e '.Buckets | any(.Name == \"devcontainer-test\")'" + +# Scenario specific tests +check "pod loaded resources" "lstk aws s3api list-buckets | jq -e '.Buckets | any(.Name == \"devcontainer-test\")'" # Report result reportResults diff --git a/test/test-utils/test-utils.sh b/test/test-utils/test-utils.sh index 381e5d5..06fd491 100644 --- a/test/test-utils/test-utils.sh +++ b/test/test-utils/test-utils.sh @@ -31,3 +31,14 @@ reportResults() { exit 0 fi } + +# Replacement for `localstack wait`: polls `lstk status` until LocalStack is up (default timeout 60s) +waitForLocalStack() { + local timeout=${1:-60} + for _ in $(seq "$timeout"); do + lstk --non-interactive status > /dev/null 2>&1 && return 0 + sleep 1 + done + echoStderr "LocalStack did not become ready within ${timeout}s" + return 1 +}