diff --git a/src/content/docs/aws/ci-pipelines/best-practices.mdx b/src/content/docs/aws/ci-pipelines/best-practices.mdx
new file mode 100644
index 000000000..1b520a676
--- /dev/null
+++ b/src/content/docs/aws/ci-pipelines/best-practices.mdx
@@ -0,0 +1,188 @@
+---
+title: CI Best Practices
+description: Commands and general practices for running LocalStack in any CI system, from authentication and tool installation to seeding state and collecting logs.
+template: doc
+sidebar:
+ order: 2
+---
+
+import { Tabs, TabItem } from '@astrojs/starlight/components';
+
+Every CI system has its own configuration syntax, runner model, and feature set.
+Consult your CI provider's own documentation for how to declare jobs, secrets, caches, and artifacts.
+This page covers the parts that are the same everywhere, such as the LocalStack-specific commands you run, and the best practices for running a LocalStack job.
+
+Whatever the provider, a CI job follows the same steps:
+
+1. Expose your CI Auth Token to the job as `LOCALSTACK_AUTH_TOKEN`.
+2. Install `lstk` and any tools your tests need, such as the AWS CLI or Terraform.
+3. Configure and start the emulator with `lstk start`.
+4. Deploy your infrastructure, using an Infrastructure as Code tool.
+5. Alternatively, seed state from a snapshot with `lstk load`.
+6. Run your tests.
+7. Collect the emulator logs as a build artifact.
+
+## Set your Auth Token
+
+Every LocalStack CI run needs a [CI Auth Token](https://app.localstack.cloud/workspace/auth-tokens), rather than a personal Developer Auth Token.
+Store the token in your CI system as `LOCALSTACK_AUTH_TOKEN`.
+Every CI provider offers somewhere to keep sensitive values, and most distinguish secrets from plain environment variables.
+Secrets are masked in job logs and withheld from forked-repository builds.
+Never commit a token to your repository or paste it into a pipeline definition.
+
+The `lstk` CLI tool automatically passes the `LOCALSTACK_AUTH_TOKEN` value into the emulator container when it starts.
+There is no need to invoke `lstk login`, which is only useful in an interactive session.
+
+## Install the tools
+
+Your job needs the `lstk` CLI, plus whichever AWS tooling your tests use.
+Many hosted runners already ship Docker, the AWS CLI, and Terraform, so check your runner image before adding an install step.
+
+### `lstk`
+
+[`lstk`](/aws/developer-tools/running-localstack/lstk/) is the recommended way to run and manage LocalStack.
+It is a single binary, so installing it in CI is quick with tools such as `npm` or `brew`.
+
+
+
+
+```bash
+npm install -g @localstack/lstk
+```
+
+
+
+
+```bash
+brew install localstack/tap/lstk
+```
+
+
+
+
+See the [`lstk` installation guide](/aws/developer-tools/running-localstack/lstk/#installation) for all installation methods.
+`lstk` also needs a working Docker daemon on the runner, with access to a Docker socket so the emulator can spawn its own containers for services such as Lambda and ECS.
+
+### AWS CLI
+
+`lstk aws` proxies your host `aws` binary with the LocalStack endpoint, credentials, and region already configured, so the AWS CLI must be installed separately (if not already installed in your CI system).
+
+Refer to the [AWS CLI installation instructions](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) for details, and to the [AWS CLI guide](/aws/connecting/aws-cli/) for using it against LocalStack.
+
+### Terraform
+
+`lstk terraform` drives the real `terraform` binary, so Terraform itself must be on the job's `PATH`.
+Install it with your provider's setup step where one exists (for example `hashicorp/setup-terraform` on GitHub Actions), or install it directly.
+
+Refer to the [Terraform installation instructions](https://developer.hashicorp.com/terraform/install) for details, and to the [Terraform guide](/aws/connecting/infrastructure-as-code/terraform/) for using it against LocalStack.
+
+## Configure the emulator
+
+The `lstk` CLI tool uses a `config.toml` file to discover the required configuration parameters when starting the emulator.
+Commit a `.lstk/config.toml` to your repository, and both your developers and your CI jobs get the same emulator configuration, with no environment variables to duplicate across pipeline files.
+`lstk` picks up `./.lstk/config.toml` automatically when it is run from the root of your source tree:
+
+```toml
+# .lstk/config.toml
+[[containers]]
+type = "aws" # Emulator type: "aws", "snowflake", or "azure"
+tag = "2026.4" # Pin the image tag for reproducible builds
+port = "4566"
+env = ["ci"] # Apply the [env.ci] profile below
+
+[env.ci]
+DEBUG = "1"
+```
+
+See the [configuration reference](/aws/developer-tools/running-localstack/lstk/#configuration) for every available field.
+
+Keep a single `.lstk/config.toml` for local development and CI where you can.
+However, if a CI job needs different settings, pass an alternative file with `lstk --config ./ci/lstk.toml start`.
+
+## Start the emulator
+
+Start LocalStack with a single command:
+
+```bash
+lstk start
+```
+
+`lstk start` brings the LocalStack emulator all the way to a ready state.
+It pulls the container image if needed, validates your license, starts the container, and returns only once the emulator is ready, so there is no need for a separate wait or health-check step.
+If startup fails, the command exits with a non-zero return code, causing your CI job to fail.
+
+For machine-readable output, add the global `--json` flag to any command.
+See [structured output](/aws/developer-tools/running-localstack/lstk/#structured-output) and [exit codes](/aws/developer-tools/running-localstack/lstk/#exit-codes) if your pipeline needs to inspect results programmatically.
+
+## Seed state from Infrastructure as Code
+
+Most CI pipelines create the resources their tests need by applying the same Infrastructure as Code they use for production.
+The `lstk` proxies automatically point those tools at the emulator, without any explicit configuration.
+
+For example, with Terraform, run your usual commands through `lstk terraform` (or its `lstk tf` alias):
+
+```bash
+lstk terraform init
+lstk terraform apply -auto-approve
+```
+
+The [`lstk cdk`](/aws/connecting/infrastructure-as-code/aws-cdk/) and [`lstk sam`](/aws/connecting/infrastructure-as-code/aws-sam/) proxies work the same way, and [other IaC tools](/aws/connecting/infrastructure-as-code/) can target the emulator through its endpoint directly.
+
+## Seed state from a snapshot
+
+Rather than deploying your whole infrastructure on every run, you can seed the emulator from a [snapshot](/aws/developer-tools/snapshots/) captured earlier, either from a Cloud Pod or from a local snapshot file:
+
+```bash
+# Load a Cloud Pod (requires LOCALSTACK_AUTH_TOKEN)
+lstk load pod:my-baseline
+
+# Load a snapshot file produced by an earlier job
+lstk load ./baseline.snapshot
+```
+
+`lstk load` starts the emulator first, if it is not already running, so it can replace a separate `lstk start` step.
+Alternatively, name the snapshot in your config, and `lstk start` loads it for you on every fresh start:
+
+```toml
+[[containers]]
+type = "aws"
+port = "4566"
+snapshot = "pod:my-baseline"
+```
+
+Override the configured snapshot for a single run with `lstk start --snapshot pod:other-baseline`, or skip auto-loading entirely with `lstk start --no-snapshot`.
+
+To produce the snapshot in the first place, see [Cloud Pods](/aws/developer-tools/snapshots/cloud-pods/) and [saving snapshots locally](/aws/developer-tools/snapshots/saving-snapshots-locally/).
+
+## Run your tests
+
+Once the emulator is running, point your tooling at it.
+For Infrastructure as Code tools (such as Terraform), use the `lstk` proxy version of the tool, such as `lstk terraform`.
+
+For test suites and SDK-based code, either set the endpoint and test credentials in the job's environment:
+
+```bash
+export AWS_ENDPOINT_URL=http://localhost.localstack.cloud:4566
+export AWS_ACCESS_KEY_ID=test
+export AWS_SECRET_ACCESS_KEY=test
+```
+
+Or create a `localstack` AWS profile and select it:
+
+```bash
+lstk setup aws
+export AWS_PROFILE=localstack
+```
+
+See [connecting to LocalStack](/aws/connecting/) for the full set of options.
+
+## Collect logs
+
+The emulator container disappears when the job ends, so consider exporting the logs before the test terminates, then store them as a build artifact:
+
+```bash
+lstk logs --verbose > localstack.log
+```
+
+Run this step even when the tests fail, so you capture the logs regardless of success or failure. To make failures easier to diagnose in the first place, set `DEBUG = "1"` in your CI environment profile.
+See [logging](/aws/customization/logging/) for the available log levels.
diff --git a/src/content/docs/aws/ci-pipelines/bitbucket.md b/src/content/docs/aws/ci-pipelines/bitbucket.md
index 373651189..d9fb05a0f 100644
--- a/src/content/docs/aws/ci-pipelines/bitbucket.md
+++ b/src/content/docs/aws/ci-pipelines/bitbucket.md
@@ -3,7 +3,7 @@ title: BitBucket
description: Use LocalStack in BitBucket Pipelines.
template: doc
sidebar:
- order: 3
+ order: 4
---
## Introduction
@@ -11,19 +11,25 @@ sidebar:
[BitBucket Pipeline](https://bitbucket.org/product/features/pipelines) is a CI/CD tool that allows you to build, test, and deploy your code directly from BitBucket.
This guide will show you how to use LocalStack in BitBucket Pipelines.
+BitBucket runs your build and the Docker daemon in separate containers, and does not support mounting volumes.
+This guide therefore starts the LocalStack container directly with `docker run`, so the pipeline controls the port mappings and the Docker connection itself, and then uses the [`lstk`](/aws/developer-tools/running-localstack/lstk/) tool proxies to interact with it.
+On CI systems without those constraints, `lstk` can manage the container lifecycle as well; see [CI Best Practices](/aws/ci-pipelines/best-practices/).
+
## Setting up the BitBucket Pipeline
When you want to integrate LocalStack into your job configuration, you just have to execute the following steps:
- Specify the Docker Socket to allow the LocalStack container to access the Docker daemon.
-- Export the `AWS_ENDPOINT_URL` environment variable to point to the LocalStack endpoint.
-- Install the `localstack` CLI and `awscli-local` to interact with LocalStack's emulated services.
+- Pass your CI Auth Token to the container, which is required to start the emulator.
+- Export the `LSTK_ENDPOINT_URL` environment variable to point `lstk` at the LocalStack endpoint.
+- Install the AWS CLI and `lstk` to interact with LocalStack's emulated services.
- Start the LocalStack container in detached mode by specifying the Docker Socket and Docker Host.
+- Wait for the emulator to become ready before using it.
The following example BitBucket Pipeline configuration (`bitbucket-pipelines.yaml`) executes these steps, creates a new S3 bucket, and queries the list of S3 buckets:
```yaml showshowLineNumbers
-image: python:3.9
+image: node:22
definitions:
services:
@@ -37,26 +43,25 @@ pipelines:
services:
- docker
script:
- - export PYTHONPATH=$PYTHONPATH:$(pwd)
- export DOCKER_SOCK=$DOCKER_HOST
- - export AWS_ENDPOINT_URL="http://localhost.localstack.cloud:4566"
- - env
+ - export LSTK_ENDPOINT_URL="http://localhost.localstack.cloud:4566"
- echo "${BITBUCKET_DOCKER_HOST_INTERNAL} localhost.localstack.cloud " >> /etc/hosts
- - pip install localstack awscli-local
+ - apt-get update && apt-get install -y awscli
+ - npm install -g @localstack/lstk
+ - docker run -d --rm -p 4566:4566 -p 4510-4559:4510-4559 -e LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN:?} -e DEBUG=1 -e DOCKER_SOCK=tcp://${BITBUCKET_DOCKER_HOST_INTERNAL}:2375 -e DOCKER_HOST=tcp://${BITBUCKET_DOCKER_HOST_INTERNAL}:2375 --name localstack-aws localstack/localstack-pro
- |
- curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
- unzip awscliv2.zip
- ./aws/install
- - docker run -d --rm -p 4566:4566 -p 4510-4559:4510-4559 -e DOCKER_SOCK=tcp://${BITBUCKET_DOCKER_HOST_INTERNAL}:2375 -e DOCKER_HOST=tcp://${BITBUCKET_DOCKER_HOST_INTERNAL}:2375 --name localstack-main localstack/localstack
- - localstack wait -t 60
- - awslocal s3 mb s3://test-bucket
- - awslocal s3 ls
+ for _ in $(seq 1 60); do
+ curl -sf "${LSTK_ENDPOINT_URL}/_localstack/health" > /dev/null && break
+ sleep 2
+ done
+ - lstk aws s3 mb s3://test-bucket
+ - lstk aws s3 ls
```
## Configuring a CI Auth Token
-You can enable LocalStack for AWS by using the `localstack/localstack-pro` image and adding your CI Auth Token to the project's environment variables.
-The LocalStack container will automatically pick it up and activate the Pro features.
+For the configuration above to work, add your CI Auth Token to the project's environment variables.
+The LocalStack container will automatically pick it up and activate your LocalStack license.
Go to the [CI Auth Token page](https://app.localstack.cloud/workspace/auth-tokens) and copy your CI Auth Token.
To add a CI Auth Token to your BitBucket Pipeline:
@@ -65,24 +70,7 @@ To add a CI Auth Token to your BitBucket Pipeline:
- Select the **Settings** on the top navigation bar.
- Select **Workspace settings** from the **Settings dropdown** menu.
- On the left-hand menu, navigate to **Pipelines** and click on **Workspace variables**.
-- Add a new variable with the name `LOCALSTACK_AUTH_TOKEN` and the value of your CI Auth Token.
-
-Navigate to your BitBucket Pipeline and add the following lines to the `bitbucket-pipelines.yaml` file:
-
-```yaml showshowLineNumbers
-pipelines:
- default:
- - step:
- name: Test Localstack
- services:
- - docker
- script:
- ...
- - export LOCALSTACK_AUTH_TOKEN=$LOCALSTACK_AUTH_TOKEN
- ...
- - docker run -d --rm -p 4566:4566 -p 4510-4559:4510-4559 -e LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN:?} -e DEBUG=1 -e LS_LOG=trace -e DOCKER_SOCK=tcp://${BITBUCKET_DOCKER_HOST_INTERNAL}:2375 -e DOCKER_HOST=tcp://${BITBUCKET_DOCKER_HOST_INTERNAL}:2375 --name localstack-main localstack/localstack-pro
- ...
-```
+- Add a new variable with the name `LOCALSTACK_AUTH_TOKEN` and the value of your CI Auth Token, and mark it as **Secured**.
## Current Limitations
diff --git a/src/content/docs/aws/ci-pipelines/circleci.md b/src/content/docs/aws/ci-pipelines/circleci.md
index 5c7556148..226cfd959 100644
--- a/src/content/docs/aws/ci-pipelines/circleci.md
+++ b/src/content/docs/aws/ci-pipelines/circleci.md
@@ -3,94 +3,55 @@ title: CircleCI
description: Use LocalStack in CircleCI.
template: doc
sidebar:
- order: 2
+ order: 3
---
## Introduction
[CircleCI](https://circleci.com) is a continuous integration and continuous delivery (CI/CD) platform which uses a configuration file (usually named `.circleci/config.yml`) to define the build, test, and deployment workflows.
-This guide shows how to run LocalStack in CircleCI using the LocalStack Docker image and the LocalStack CLI.
+This guide shows how to run LocalStack in CircleCI using the [`lstk` CLI](/aws/developer-tools/running-localstack/lstk/).
## Snippets
### Start up LocalStack
-#### Default
-
```yaml showshowLineNumbers
version: '2.1'
-orbs:
- python: circleci/python@4.0.0
jobs:
localstack-test:
machine:
image: ubuntu-2204:current
steps:
- checkout
+ # LOCALSTACK_AUTH_TOKEN comes from the project's environment variables
- run:
- name: Install LocalStack CLI and awslocal
- command: |
- python3 -m pip install --user --upgrade pip
- python3 -m pip install --user localstack awscli-local[ver1]
- echo 'export PATH=$HOME/.local/bin:$PATH' >> "$BASH_ENV"
+ name: Install lstk
+ command: npm install -g @localstack/lstk
+ - run:
+ name: Configure the AWS profile
+ command: lstk setup aws
- run:
name: Start LocalStack
- command: |
- source "$BASH_ENV"
- docker pull localstack/localstack:latest
- localstack start -d
- localstack wait -t 60
+ command: lstk start
- run:
name: Test LocalStack
command: |
- awslocal s3 mb s3://test-bucket
- awslocal s3 ls
+ lstk aws s3 mb s3://test-bucket
+ lstk aws s3 ls
workflows:
localstack-test:
jobs:
- localstack-test
```
-#### Async
-
-```yaml showshowLineNumbers
-version: '2.1'
-orbs:
- python: circleci/python@4.0.0
-jobs:
- localstack-test:
- machine:
- image: ubuntu-2204:current
- steps:
- - checkout
- - run:
- name: Install LocalStack CLI and awslocal
- command: |
- python3 -m pip install --user --upgrade pip
- python3 -m pip install --user localstack awscli-local[ver1]
- echo 'export PATH=$HOME/.local/bin:$PATH' >> "$BASH_ENV"
- - run:
- name: Start LocalStack in background
- command: |
- source "$BASH_ENV"
- docker pull localstack/localstack:latest
- localstack start -d
- - run:
- name: Execute setup and tests
- command: |
- source "$BASH_ENV"
- localstack wait -t 60
- awslocal sqs create-queue --queue-name test-queue
- awslocal sqs list-queues
-workflows:
- localstack-test:
- jobs:
- - localstack-test
-```
+`lstk start` pulls the image, validates your license, and returns only once the emulator is ready, so no separate wait step is needed.
+`lstk aws` proxies the `aws` binary with LocalStack's endpoint and credentials applied, so the AWS CLI must be available on the runner; add an install step if your image does not provide it.
+`lstk setup aws` writes a `localstack` AWS profile for that binary to use. It is optional, but without it `lstk` notes on every call that no profile was found.
### Configuration
To configure LocalStack use the `environment` key on the job level or a shell command, where the latter takes higher precedence.
+`lstk start` forwards host environment variables prefixed with `LOCALSTACK_` into the container, which strips the prefix, so set `LOCALSTACK_DEBUG` to control the container's `DEBUG` option.
Read more about the [configuration options](/aws/customization/configuration-options) of LocalStack.
@@ -103,11 +64,11 @@ jobs:
machine:
image: ubuntu-2204:current
environment:
- DEBUG: 1
- LS_LOG: trace
+ LOCALSTACK_DEBUG: "1"
+ LOCALSTACK_LS_LOG: "trace"
steps:
...
- - run: localstack start -d
+ - run: lstk start
...
```
@@ -123,15 +84,15 @@ jobs:
- run:
name: Configure LocalStack
command: |
- echo 'export DEBUG=1' >> "$BASH_ENV"
- echo 'export LS_LOG=trace' >> "$BASH_ENV"
+ echo 'export LOCALSTACK_DEBUG=1' >> "$BASH_ENV"
+ echo 'export LOCALSTACK_LS_LOG=trace' >> "$BASH_ENV"
...
```
### Configuring a CI Auth Token
To enable LocalStack for AWS, you need to add your LocalStack CI Auth Token to the project's environment variables.
-The LocalStack container will automatically pick it up and activate the licensed features.
+`lstk` will automatically pick it up and activate the licensed features.
Go to the [CI Auth Token page](https://app.localstack.cloud/workspace/auth-tokens) and copy your CI Auth Token.
To add the CI Auth Token to your CircleCI project, follow these steps:
@@ -144,38 +105,6 @@ To add the CI Auth Token to your CircleCI project, follow these steps:
After adding the variable, CircleCI injects `LOCALSTACK_AUTH_TOKEN` into your job environment.
-```yaml showshowLineNumbers
-version: '2.1'
-orbs:
- python: circleci/python@4.0.0
-jobs:
- localstack-test:
- machine:
- image: ubuntu-2204:current
- steps:
- - checkout
- - run:
- name: Install LocalStack CLI and awslocal
- command: |
- python3 -m pip install --user --upgrade pip
- python3 -m pip install --user localstack awscli-local[ver1]
- echo 'export PATH=$HOME/.local/bin:$PATH' >> "$BASH_ENV"
- - run:
- name: Start LocalStack
- command: |
- source "$BASH_ENV"
- docker pull localstack/localstack:latest
- localstack start -d
- localstack wait -t 60
- - run:
- name: Verify LocalStack setup
- command: localstack logs | rg "activated|auth token|ready"
-workflows:
- localstack-test:
- jobs:
- - localstack-test
-```
-
### Dump LocalStack logs
```yaml showshowLineNumbers
@@ -188,7 +117,8 @@ jobs:
...
- run:
name: Dump LocalStack logs
- command: localstack logs | tee localstack.log
+ when: always
+ command: lstk logs --verbose | tee localstack.log
- store_artifacts:
path: localstack.log
name: localstack-logs
@@ -222,21 +152,18 @@ jobs:
image: ubuntu-2204:current
steps:
- - run: python3 -m pip install localstack awscli-local[ver1]
- - run: |
- docker pull localstack/localstack:latest
- localstack start -d
- localstack wait -t 60
+ - run: npm install -g @localstack/lstk
+ - run: lstk start
...
- run:
name: Load state if exists
- command: localstack pod load || true
+ command: lstk load pod: || true
...
# Deploy infrastructure changes
...
- run:
name: Save Cloud Pod
- command: localstack pod save
+ command: lstk save pod:
workflows:
@@ -255,15 +182,12 @@ jobs:
image: ubuntu-2204:current
steps:
- - run: python3 -m pip install localstack awscli-local[ver1]
- - run: |
- docker pull localstack/localstack:latest
- localstack start -d
- localstack wait -t 60
+ - run: npm install -g @localstack/lstk
+ - run: lstk start
...
- run:
name: Load Cloud Pod
- command: localstack pod load
+ command: lstk load pod:
...
# Run some tests
@@ -302,21 +226,18 @@ jobs:
image: ubuntu-2204:current
steps:
- - run: python3 -m pip install localstack awscli-local[ver1]
- - run: |
- docker pull localstack/localstack:latest
- localstack start -d
- localstack wait -t 60
+ - run: npm install -g @localstack/lstk
+ - run: lstk start
...
- run:
name: Load Cloud Pod
- command: localstack pod load || true
+ command: lstk load pod: || true
...
# Deploy infrastructure
...
- run:
name: Save Cloud Pod
- command: localstack pod save
+ command: lstk save pod:
- run:
name: Trigger other workflows
# Replace placeholders with right values
@@ -333,15 +254,12 @@ jobs:
image: ubuntu-2204:current
steps:
- - run: python3 -m pip install localstack awscli-local[ver1]
- - run: |
- docker pull localstack/localstack:latest
- localstack start -d
- localstack wait -t 60
+ - run: npm install -g @localstack/lstk
+ - run: lstk start
...
- run:
name: Load state if exists
- command: localstack pod load || true
+ command: lstk load pod: || true
...
@@ -362,110 +280,6 @@ workflows:
...
```
-#### Ephemeral Instance (Preview)
-
-Find out more about [Ephemeral Instances](/aws/developer-tools/cloud-sandbox/ephemeral-instances).
-
-##### Same job
-
-```yaml showshowLineNumbers
-...
-jobs:
- do-work:
- machine:
- image: ubuntu-2204:current
- steps:
- - run:
- name: Create Ephemeral Instance
- command: |
- response=$(curl -X POST \
- -H "ls-api-key: $LOCALSTACK_AUTH_TOKEN" \
- -H "authorization: token $LOCALSTACK_AUTH_TOKEN" \
- -H "content-type: application/json" \
- -d '{"auto_load_pod":"false"}' \
- https://api.localstack.cloud/v1/previews/my-circleci-state)
- endpoint_url=$(echo "$response" | jq -r '.endpointUrl')
- if [ -z "$endpoint_url" ] || [ "$endpoint_url" = "null" ]; then
- echo "Unable to create preview environment. API response: $response"
- exit 1
- fi
- echo "export AWS_ENDPOINT_URL=$endpoint_url" >> "$BASH_ENV"
- - run:
- name: Output the ephemeral instance address
- command: echo "$AWS_ENDPOINT_URL"
-...
-workflows:
- use-ephemeral-instance:
- jobs:
- - do-work
-...
-```
-
-##### Multiple jobs
-
-```yaml showshowLineNumbers
-...
-jobs:
- setup-instance:
- machine:
- image: ubuntu-2204:current
- steps:
- - run:
- name: Create Ephemeral Instance
- command: |
- response=$(curl -X POST \
- -H "ls-api-key: $LOCALSTACK_AUTH_TOKEN" \
- -H "authorization: token $LOCALSTACK_AUTH_TOKEN" \
- -H "content-type: application/json" \
- -d '{"auto_load_pod":"false"}' \
- https://api.localstack.cloud/v1/previews/my-circleci-state)
- endpoint_url=$(echo "$response" | jq -r '.endpointUrl')
- if [ -z "$endpoint_url" ] || [ "$endpoint_url" = "null" ]; then
- echo "Unable to create preview environment. API response: $response"
- exit 1
- fi
- echo "export AWS_ENDPOINT_URL=$endpoint_url" >> ls-env-vars
- - run:
- name: Persist AWS Endpoint URL
- command: cat ls-env-vars
- - persist_to_workspace:
- root: .
- paths:
- - ls-env-vars
-
- run-test:
- machine:
- image: ubuntu-2204:current
- steps:
- - attach_workspace:
- at: .
- - run:
- name: Set up LS env variables
- command: cat ./ls-env-vars >> $BASH_ENV
- - run:
- name: Output the ephemeral instance address
- command: echo "$AWS_ENDPOINT_URL"
-...
- # Run any logic against the Ephemeral Instance,
- # then stop when not needed anymore
- - run:
- name: Stop Ephemeral Instance
- command: |
- # Replace with the id returned by the API in setup-instance.
- curl -X DELETE \
- -H "ls-api-key: $LOCALSTACK_AUTH_TOKEN" \
- -H "authorization: token $LOCALSTACK_AUTH_TOKEN" \
- https://api.localstack.cloud/v1/previews/
-
-...
-workflows:
- use-ephemeral-instance:
- jobs:
- - setup-instance
- - run-test
-...
-```
-
#### Workspace
This strategy persist LocalStack's state between jobs for the current workflow.
@@ -477,41 +291,37 @@ jobs:
machine:
image: ubuntu-2204:current
steps:
- - run: python3 -m pip install localstack awscli-local[ver1]
- - run: |
- docker pull localstack/localstack:latest
- localstack start -d
- localstack wait -t 60
+ - run: npm install -g @localstack/lstk
+ - run: lstk start
...
# LocalStack already running and deployed infrastructure
- run:
- name: Export state
- command: localstack state export ls-state.zip
+ name: Save a snapshot
+ command: lstk save ./ls-state.snapshot
- persist_to_workspace:
- paths:
- - ls-state.zip
+ paths:
+ - ls-state.snapshot
# Store state as artifact for local debugging
- - store_artifact:
- key: ls-state
- paths: ls-state.zip
+ - store_artifacts:
+ path: ls-state.snapshot
+ name: ls-state
...
localstack-load-state:
machine:
image: ubuntu-2204:current
steps:
- - run: python3 -m pip install localstack awscli-local[ver1]
- - run: |
- docker pull localstack/localstack:latest
- localstack start -d
- localstack wait -t 60
+ - run: npm install -g @localstack/lstk
+ - run: lstk start
...
# LocalStack already running
- attach_workspace:
at: .
- run:
- name: Import state
+ name: Load the snapshot
command: |
- test -f ls-state.zip && localstack state import ls-state.zip
+ if [ -f ls-state.snapshot ]; then
+ lstk load ./ls-state.snapshot --merge=overwrite
+ fi
...
workflows:
localstack-build:
@@ -520,7 +330,7 @@ jobs:
- localstack-load-state
```
-More information about Localstack's [state import/export](/aws/developer-tools/snapshots/saving-snapshots-locally).
+More information about Localstack's [snapshots](/aws/developer-tools/snapshots/saving-snapshots-locally).
#### Cache
@@ -534,11 +344,8 @@ jobs:
machine:
image: ubuntu-2204:current
steps:
- - run: python3 -m pip install localstack awscli-local[ver1]
- - run: |
- docker pull localstack/localstack:latest
- localstack start -d
- localstack wait -t 60
+ - run: npm install -g @localstack/lstk
+ - run: lstk start
...
# LocalStack already running
# Let's restore previous workflow run's LocalStack state
@@ -546,34 +353,37 @@ jobs:
# Use latest "ls-state" prefixed cache
key: ls-state-
- run:
- name: Import state
- command: test -f ls-state.zip && localstack state import ls-state.zip
+ name: Load the snapshot
+ command: |
+ if [ -f ls-state.snapshot ]; then
+ lstk load ./ls-state.snapshot --merge=overwrite
+ fi
...
# Infrastructure had been updated
# Let's update cached LocalStack state
- run:
- name: Export state
- command: localstack state export ls-state.zip
+ name: Save a snapshot
+ command: lstk save ./ls-state.snapshot
- save_cache:
- key: ls-state-{{checksum ls-state.zip}}
- paths: ls-state.zip
+ key: ls-state-{{checksum ls-state.snapshot}}
+ paths: ls-state.snapshot
...
localstack-do-work:
machine:
image: ubuntu-2204:current
steps:
- - run: python3 -m pip install localstack awscli-local[ver1]
- - run: |
- docker pull localstack/localstack:latest
- localstack start -d
- localstack wait -t 60
+ - run: npm install -g @localstack/lstk
+ - run: lstk start
# LocalStack already running
- restore_cache:
# Use latest "ls-state" prefixed cache
key: ls-state-
- run:
- name: Import state
- command: test -f ls-state.zip && localstack state import ls-state.zip
+ name: Load the snapshot
+ command: |
+ if [ -f ls-state.snapshot ]; then
+ lstk load ./ls-state.snapshot --merge=overwrite
+ fi
...
@@ -586,4 +396,4 @@ workflows:
...
```
-More information about [state management](/aws/developer-tools/snapshots/saving-snapshots-locally).
\ No newline at end of file
+More information about [snapshots](/aws/developer-tools/snapshots/saving-snapshots-locally).
\ No newline at end of file
diff --git a/src/content/docs/aws/ci-pipelines/codebuild.md b/src/content/docs/aws/ci-pipelines/codebuild.md
index 255c699b3..da4a04aeb 100644
--- a/src/content/docs/aws/ci-pipelines/codebuild.md
+++ b/src/content/docs/aws/ci-pipelines/codebuild.md
@@ -3,14 +3,16 @@ title: CodeBuild
description: Use LocalStack in CodeBuild.
template: doc
sidebar:
- order: 6
+ order: 7
---
## Introduction
[AWS CodeBuild](https://docs.aws.amazon.com/codebuild/latest/userguide/welcome.html) is a managed AWS service for the build and testing phases of software development.
CodeBuild allows you to define your build project, set the source code location, and handles the building and testing, while supporting various programming languages, build tools, and runtime environments.
-LocalStack supports CodeBuild out of the box and can be easily integrated into your pipeline to run your tests against a cloud emulator.
+This guide shows how to run LocalStack in CodeBuild using the [`lstk` CLI](/aws/developer-tools/running-localstack/lstk/).
+
+The CodeBuild standard images already provide Docker, Node.js, and the AWS CLI, so `lstk` is the only part that needs installing.
:::note
LocalStack depends on the Docker socket to emulate your infrastructure.
@@ -19,133 +21,68 @@ To enable it, update your project by ticking **Environment > Additional Configur
## Snippets
-CodeBuild has the capability to use LocalStack's GitHub Action.
-
### Start up LocalStack
-#### Native Runner
+LocalStack requires a CI Auth Token to run.
+Go to the [CI Auth Token page](https://app.localstack.cloud/workspace/auth-tokens) and copy your CI Auth Token, then add it to the project's environment variables:
-```yml showshowLineNumbers
-version: 0.2
-...
-phases:
- pre_build:
- commands:
- - pip3 install localstack awscli
- - docker pull public.ecr.aws/localstack/localstack:latest
- - localstack start -d
- - localstack wait -t 30
-```
+- Navigate to your project dashboard, click **Edit** to open the dropdown, and select **Environment**.
+- Click on **Additional configuration** and navigate to the **Environment variables** section.
+- Specify **Name** as `LOCALSTACK_AUTH_TOKEN` and **Value** as your CI Auth Token.
+Specify **Type** as per your requirement.
+- Click on **Update environment** to save your environment variables.
-#### GitHub Actions Runner
+`lstk` automatically recognizes the token and activates the licensed features.
+You can then install `lstk` and start the emulator in your buildspec file:
```yml showshowLineNumbers
version: 0.2
phases:
+ install:
+ runtime-versions:
+ nodejs: 22
+ commands:
+ - npm install -g @localstack/lstk
pre_build:
- steps:
- - run: docker pull public.ecr.aws/localstack/localstack:latest
- - run: docker image tag public.ecr.aws/localstack/localstack-pro:latest localstack/localstack:latest
- - name: Start LocalStack
- uses: LocalStack/setup-localstack@v0.2.2
- with:
- image-tag: 'latest'
- install-awslocal: 'true'
+ commands:
+ # LOCALSTACK_AUTH_TOKEN comes from the project's environment variables
+ - lstk setup aws
+ - lstk start
+ build:
+ commands:
+ - lstk aws s3 mb s3://test-bucket
+ - lstk aws s3 ls
```
-### Configuration
+`lstk start` pulls the image, validates your license, and returns only once the emulator is ready, so no separate wait step is needed.
+`lstk aws` proxies the runner's `aws` binary with LocalStack's endpoint and credentials applied.
+`lstk setup aws` writes a `localstack` AWS profile for that binary to use.
-Get know more about the LocalStack [config options](/aws/customization/configuration-options).
-
-#### Native Runner
-
-```yml showshowLineNumbers
-version: 0.2
-
-env:
- variables:
- DEBUG: 1
-...
-phases:
-...
-```
+### Configuration
-#### GitHub Actions Runner
+To set LocalStack configuration options, pass them as `LOCALSTACK_`-prefixed environment variables.
+`lstk start` forwards those into the container which strips the prefix, so `LOCALSTACK_DEBUG` sets the container's `DEBUG` option.
```yml showshowLineNumbers
version: 0.2
env:
variables:
- DEBUG: 1
+ LOCALSTACK_DEBUG: "1"
+ LOCALSTACK_LS_LOG: "trace"
...
-
phases:
- pre_build:
- steps:
- ...
- - name: Start LocalStack
- uses: LocalStack/setup-localstack@v0.2.2
- with:
- image-tag: 'latest'
- configuration: LS_LOG=trace
...
```
-### Configuring a CI Auth Token
-
-To enable LocalStack for AWS features, you need to add your LocalStack CI Auth Token to the project's environment variables.
-The LocalStack container will automatically pick it up and activate the licensed features.
-
-Go to the [CI Auth Token page](https://app.localstack.cloud/workspace/auth-tokens) and copy your CI Auth Token.
-To add the CI Auth Token to your CodeBuild project, follow these steps:
-
-- Navigate to your project dashboard, click **Edit** to open the dropdown, and select **Environment**.
-- Click on **Additional configuration** and navigate to the **Environment variables** section.
-- Specify **Name** as `LOCALSTACK_AUTH_TOKEN` and **Value** as your CI Auth Token.
-Specify **Type** as per your requirement.
-
-Click on **Update environment** to save your environment variables.
-Navigate to the buildspec file and change the Docker image to `public.ecr.aws/localstack/localstack-pro:latest`:
-
-#### Native Runner
-
-```yaml showshowLineNumbers
-...
-phases:
- pre_build:
- commands:
- - pip3 install localstack awscli
- - docker pull public.ecr.aws/localstack/localstack-pro:latest
-...
-```
-
-#### GitHub Actions Runner
-
-```yml showshowLineNumbers
-...
-phases:
- pre_build:
- steps:
- - run: docker pull public.ecr.aws/localstack/localstack-pro:latest
- - run: docker image tag public.ecr.aws/localstack/localstack-pro:latest localstack/localstack-pro:latest
- - name: Start LocalStack
- uses: LocalStack/setup-localstack@v0.2.2
- with:
- image-tag: 'latest'
- use-pro: 'true'
-...
-```
+Settings that apply to every run belong in an [`[env.*]` profile](/aws/developer-tools/running-localstack/lstk/#configuration) in a `.lstk/config.toml` committed to your repository, which also lets you pin the image tag.
+Read more about the [configuration options](/aws/customization/configuration-options) of LocalStack.
### Dump LocalStack logs
```yaml showshowLineNumbers
...
-artifacts:
- files:
- - localstack.log
-
phases:
pre_build:
commands:
@@ -158,21 +95,21 @@ phases:
post_build:
commands:
# Dump logs on build fail
- - '[ ${CODEBUILD_BUILD_SUCCEEDING:-0} -eq 0 ] (localstack logs | tee localstack.log) || true'
+ - '[ ${CODEBUILD_BUILD_SUCCEEDING:-0} -eq 0 ] && (lstk logs --verbose | tee localstack.log) || true'
...
# Optionally store dumped logs as artifact
-artifact:
+artifacts:
files:
- localstack.log
```
### Store LocalStack state
-#### Cloud Pods
+You can preserve your AWS infrastructure with LocalStack in various ways.
-Find more information about cloud pods [here](/aws/developer-tools/snapshots/cloud-pods).
+#### Cloud Pods
-##### Native Runner
+Find more information about Cloud Pods [here](/aws/developer-tools/snapshots/cloud-pods).
```yml showshowLineNumbers
...
@@ -181,92 +118,47 @@ phases:
commands:
...
# LocalStack is up and running already
- - localstack pod load || true
+ # Allow the load to fail as the pod does not exist at first run
+ - lstk load pod: || true
...
- - localstack pod save
+ - lstk save pod:
...
```
-##### GitHub Actions Runner
+#### Artifact
-```yml showshowLineNumbers
-...
-phases:
- pre_build:
- steps:
- # LocalStack is up and running already
- - name: Load the Cloud Pod
- continue-on-error: true # Allow it to fail as pod does not exist at first run
- uses: LocalStack/setup-localstack@v0.2.2
- with:
- state-backend: cloud-pods
- name:
- action: load
- skip-startup: 'true'
- ...
- - name: Save the Cloud Pod
- uses: LocalStack/setup-localstack@v0.2.2
- with:
- state-backend: cloud-pods
- state-name:
- ...
-```
+Instead of the LocalStack platform, you can keep the state as a local snapshot file and move it between builds with CodeBuild's own artifact storage.
-#### Ephemeral Instances (Preview)
+Find out more about [snapshots](/aws/developer-tools/snapshots/saving-snapshots-locally/).
```yml showshowLineNumbers
...
phases:
pre_build:
commands:
- ...
+ # LocalStack is up and running already
- |
- response=$(curl -X POST -d '{"auto_load_pod": "false"}' \
- -H 'ls-api-key: $LOCALSTACK_API_KEY' \
- -H 'authorization: token $LOCALSTACK_API_KEY' \
- -H 'content-type: application/json' \
- https://api.localstack.cloud/v1/previews/my-localstack-state)
-
- if [ "$endpointUrl" = "null" ] || [ "$endpointUrl" = "" ]; then
- echo "Unable to create preview environment. API response: $response"
- exit 1
- fi
- echo "Created preview environment with endpoint URL: $endpointUrl"
-
- export AWS_ENDPOINT_URL=$endpointUrl
+ if [ -f ls-state.snapshot ]; then
+ lstk load ./ls-state.snapshot --merge=overwrite
+ fi
...
-```
-
-Find out more about [ephemeral instances](/aws/developer-tools/cloud-sandbox/ephemeral-instances).
-
-#### Artifact
-
-Find out more about [state management](/aws/developer-tools/snapshots/saving-snapshots-locally/).
-
-```yml showshowLineNumbers
+ - lstk save ./ls-state.snapshot
...
-phases:
- pre_build:
- # LocalStack is up and running already
- - (test -f ./ls-state-pod.zip && localstack state import ./ls-state-pod.zip) || true
- ...
- - localstack state export ./ls-state-pod.zip
-...
-artifact:
+artifacts:
files:
- - ls-state-pod.zip
+ - ls-state.snapshot
```
Alternatively save as a secondary artifact:
```yml showshowLineNumbers
...
-artifact:
+artifacts:
...
secondary-artifacts:
ls-state:
files:
- - ls-state-pod.zip
+ - ls-state.snapshot
...
```
@@ -274,54 +166,43 @@ To use previously stored artifacts as inputs, set them as a source in the projec
#### Cache
-Additional information about [state export and import](/aws/developer-tools/snapshots/saving-snapshots-locally/).
-
-##### Native Runner
-
```yml showshowLineNumbers
...
phases:
pre_build:
commands:
- # LocalStack is up and running already
- - (test -f ./ls-state-pod.zip && localstack state import ./ls-state-pod.zip) || true
- ...
- - localstack state export ./ls-state-pod.zip
-...
-cache:
- paths:
- - 'ls-state-pod.zip'
-```
-
-##### GitHub Actions Runner
-
-```yml showshowLineNumbers
-...
-phases:
- pre_build:
- steps:
- - run: (test -f ./ls-state-pod.zip && localstack state import ./ls-state-pod.zip) || true
+ # LocalStack is up and running already
+ - |
+ if [ -f ls-state.snapshot ]; then
+ lstk load ./ls-state.snapshot --merge=overwrite
+ fi
...
- - run: localstack state export ./ls-state-pod.zip
+ - lstk save ./ls-state.snapshot
...
cache:
paths:
- - 'ls-state-pod.zip'
+ - 'ls-state.snapshot'
```
## Current Limitations
-- We recommend using the `public.ecr.aws/localstack/localstack:latest` image to start LocalStack, instead of the `localstack/localstack:latest` image.
- LocalStack mirrors the Docker Hub image to the public ECR repository.
- You can use the Docker Hub image as well, though you may run into the following error:
+- `lstk` pulls the emulator image from Docker Hub by default, where you may run into the following error:
```bash
toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit
```
- To resolve this use your Docker Hub account credentials to pull the image.
+ To resolve this, either use your Docker Hub account credentials to pull the image, or point `lstk` at LocalStack's public ECR mirror with the [`image` field](/aws/developer-tools/running-localstack/lstk/#custom-container-image) in `.lstk/config.toml`:
+
+ ```toml
+ [[containers]]
+ type = "aws"
+ port = "4566"
+ image = "public.ecr.aws/localstack/localstack-pro"
+ tag = "latest"
+ ```
+
- LocalStack depends on the Docker socket to emulate your infrastructure.
To enable it, update your project by ticking **Environment > Additional Configuration > Privileged > Enable this flag if you want to build Docker Images or want your builds to get elevated privileges**.
-- AWS states in its [documentation](https://docs.aws.amazon.com/codebuild/latest/userguide/action-runner-buildspec.html#action-runner-limitations) GitHub Actions Runners are not available for **webhook triggered open Git repositories**.
-- Be aware that you can only use either the _Native Runner_ or the _GitHub Actions Runner_ snippets in the same phase
-For further information see the official CodeBuild [documentation](https://docs.aws.amazon.com/codebuild/latest/userguide/action-runner-buildspec.html).
\ No newline at end of file
+
+For further information see the official CodeBuild [documentation](https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html).
diff --git a/src/content/docs/aws/ci-pipelines/github-actions.md b/src/content/docs/aws/ci-pipelines/github-actions.md
index a52baebcb..e739ee38e 100644
--- a/src/content/docs/aws/ci-pipelines/github-actions.md
+++ b/src/content/docs/aws/ci-pipelines/github-actions.md
@@ -3,43 +3,25 @@ title: GitHub Actions
description: Use LocalStack in GitHub Actions.
template: doc
sidebar:
- order: 4
+ order: 5
---
-This page contains easily customisable snippets to show you how to manage LocalStack in a GitHub Actions pipeline.
+This page contains easily customizable snippets to show you how to manage LocalStack in a GitHub Actions pipeline.
-## Snippets
-
-### Start up Localstack
-
-```yaml showshowLineNumbers
-- name: Start LocalStack
- uses: LocalStack/setup-localstack@v0.2.2
- with:
- image-tag: 'latest'
- install-awslocal: 'true'
-```
-
-### Configuration
-
-To set LocalStack configuration options, you can use the `configuration` input parameter.
-For example, to set the `DEBUG` configuration option, you can use the following configuration:
+The GitHub-hosted `ubuntu-latest` runner already provides Docker, Node.js, and the AWS CLI, so `lstk` is the only part that needs installing.
+On a self-hosted runner, add install steps for whichever of those are missing.
-```yml showshowLineNumbers
-- name: Start LocalStack
- uses: LocalStack/setup-localstack@v0.2.2
- with:
- image-tag: 'latest'
- install-awslocal: 'true'
- configuration: DEBUG=1
-```
+:::caution
+The [`LocalStack/setup-localstack`](https://github.com/localstack/setup-localstack) action is no longer supported with `lstk`.
+Install and drive [`lstk`](/aws/developer-tools/running-localstack/lstk/) directly in a `run` step, as shown in the snippets below.
+:::
-You can add extra configuration options by separating them with a comma.
+## Snippets
-### Configure a CI Auth Token
+### Start up Localstack
To enable LocalStack for AWS, you need to add your LocalStack CI Auth Token to the project's environment variables.
-The LocalStack container will automatically pick it up and activate the licensed features.
+`lstk` will automatically pick it up and activate the licensed features.
Go to the [CI Auth Token page](https://app.localstack.cloud/workspace/auth-tokens) and copy your CI Auth Token.
To add the CI Auth Token to your GitHub project, follow these steps:
@@ -48,27 +30,54 @@ To add the CI Auth Token to your GitHub project, follow these steps:
- Enter `LOCALSTACK_AUTH_TOKEN` as the name of the secret and paste your CI Auth Token as the value.
Click **Add secret** to save your secret.
-You can then use our [`setup-localstack`](https://github.com/localstack/setup-localstack) GitHub Action to start your LocalStack container, with the `LOCALSTACK_AUTH_TOKEN` environment variable:
+You can then install `lstk` and start the emulator, passing the secret to the step:
```yaml showshowLineNumbers
+- name: Install lstk
+ run: npm install -g @localstack/lstk
+
+- name: Configure the AWS profile
+ run: lstk setup aws
+
- name: Start LocalStack
- uses: LocalStack/setup-localstack@v0.2.3
- with:
- image-tag: 'latest'
- install-awslocal: 'true'
- use-pro: 'true'
+ run: lstk start
+ env:
+ LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
+```
+
+`lstk start` pulls the image, validates your license, and returns only once the emulator is ready, so no separate wait step is needed.
+To pin the image tag, commit a [`.lstk/config.toml`](/aws/developer-tools/running-localstack/lstk/#configuration) to your repository rather than passing it on the command line.
+Where several steps run `lstk`, set `LOCALSTACK_AUTH_TOKEN` once at the job level instead of repeating it on every step.
+`lstk setup aws` writes a `localstack` AWS profile for the runner's `aws` binary to use. It is optional, but without it `lstk` notes on every call that no profile was found.
+
+### Configuration
+
+To set LocalStack configuration options, pass them as `LOCALSTACK_`-prefixed environment variables.
+`lstk start` forwards those into the container, which strips the prefix, so `LOCALSTACK_DEBUG` sets the container's `DEBUG` option.
+For example:
+
+```yml showshowLineNumbers
+- name: Start LocalStack
+ run: lstk start
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
+ LOCALSTACK_DEBUG: "1"
```
+You can add extra configuration options as further `LOCALSTACK_`-prefixed variables.
+Settings that apply to every run belong in an [`[env.*]` profile](/aws/developer-tools/running-localstack/lstk/#configuration) in `.lstk/config.toml` instead.
+
### Dump Localstack logs
```yaml showshowLineNumbers
- name: Show localstack logs
+ if: always()
run: |
- localstack logs | tee localstack.log
+ lstk logs --verbose | tee localstack.log
```
+`if: always()` makes the step run even after a failing test, which is when the logs matter most.
+
### Store Localstack state
You can preserve your AWS infrastructure with Localstack in various ways.
@@ -78,24 +87,15 @@ You can preserve your AWS infrastructure with Localstack in various ways.
```yaml showshowLineNumbers
...
# Localstack is up and running already
-- name: Load the Cloud Pod
+- name: Load the Cloud Pod
continue-on-error: true # Allow it to fail as pod does not exist at first run
- uses: LocalStack/setup-localstack@v0.2.2
- with:
- state-backend: cloud-pods
- state-name:
- state-action: load
- skip-startup: 'true'
+ run: lstk load pod:
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
...
-- name: Save the Cloud Pod
- uses: LocalStack/setup-localstack@v0.2.2
- with:
- state-backend: cloud-pods
- state-name:
- state-action: save
+- name: Save the Cloud Pod
+ run: lstk save pod:
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
...
@@ -103,75 +103,41 @@ You can preserve your AWS infrastructure with Localstack in various ways.
Find more information about cloud pods [here](/aws/developer-tools/snapshots/cloud-pods).
-#### Ephemeral Instance (Preview)
-
-Our Github Action contains the prebuilt functionality to spin up an ephemeral instance.
-
-First you need to deploy the preview:
-
-```yaml showshowLineNumbers
-name: Create PR Preview
-
-on:
- pull_request:
- types: [opened, synchronize, reopened]
-
-jobs:
- test:
- runs-on: ubuntu-latest
- timeout-minutes: 15
- permissions:
- pull-requests: write
- steps:
- ...
-
- - name: Deploy Preview
- uses: LocalStack/setup-localstack@v0.2.2
- env:
- AWS_DEFAULT_REGION: us-east-1
- AWS_REGION: us-east-1
- AWS_ACCESS_KEY_ID: test
- AWS_SECRET_ACCESS_KEY: test
- with:
- state-backend: ephemeral
- state-action: start
- github-token: ${{ secrets.GITHUB_TOKEN }}
- skip-ephemeral-stop: 'true' # We want our instance keep running
- preview-cmd: bin/deploy.sh
-```
-
-Find out more about ephemeral instances [here](/aws/developer-tools/cloud-sandbox/ephemeral-instances).
-
#### Artifact
+Instead of the LocalStack platform, you can keep the state as a local snapshot file and move it between runs with GitHub's own artifact storage.
+
```yaml showshowLineNumbers
...
-- name: Start LocalStack and Load State
- uses: LocalStack/setup-localstack@v0.2.2
- continue-on-error: true # Allow it to fail as pod does not exist at first run
+- name: Download the previous state
+ continue-on-error: true # Allow it to fail as the artifact does not exist at first run
+ uses: actions/download-artifact@v4
with:
- install-awslocal: 'true'
- state-backend: cloud-pods
- state-action: load
- state-name: my-ls-state
+ name: my-ls-state
+
+- name: Start LocalStack and load the state
+ run: |
+ lstk start
+ if [ -f ls-state.snapshot ]; then
+ lstk load ./ls-state.snapshot --merge=overwrite
+ fi
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
...
-- name: Save LocalStack State
- uses: LocalStack/setup-localstack@v0.2.2
+- name: Save the state
+ run: lstk save ./ls-state.snapshot
+
+- name: Upload the state
+ uses: actions/upload-artifact@v4
with:
- install-awslocal: 'true'
- state-backend: cloud-pods
- state-action: save
- state-name: my-ls-state
- env:
- LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
+ name: my-ls-state
+ path: ls-state.snapshot
...
```
-More information about Cloud Pods [here](/aws/developer-tools/snapshots/cloud-pods/).
+More information about [snapshots](/aws/developer-tools/snapshots/saving-snapshots-locally/).
## Current Limitations
diff --git a/src/content/docs/aws/ci-pipelines/gitlab-ci.md b/src/content/docs/aws/ci-pipelines/gitlab-ci.md
index 081924eb6..d4e60165a 100644
--- a/src/content/docs/aws/ci-pipelines/gitlab-ci.md
+++ b/src/content/docs/aws/ci-pipelines/gitlab-ci.md
@@ -3,14 +3,12 @@ title: GitLab CI
description: Use LocalStack in GitLab CI.
template: doc
sidebar:
- order: 5
+ order: 6
---
-This page contains easily customisable snippets to show you how to manage LocalStack in a GitLab CI pipeline.
+This page contains easily customizable snippets to show you how to manage LocalStack in a GitLab CI pipeline with the [`lstk` CLI](/aws/developer-tools/running-localstack/lstk/).
-## Snippets
-
-### Start up Localstack
+GitLab runs your job in one container and the Docker daemon in another, so every snippet below pairs the job with a Docker-in-Docker (`dind`) service.
:::tip
While working with a Docker-in-Docker (`dind`) setup, the Docker runner requires `privileged` mode.
@@ -18,36 +16,24 @@ You must always use `privileged = true` in your GitLab CI's `config.toml` file w
For more information, see [GitLab CI Docker-in-Docker](https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-docker-in-docker-executor) documentation.
:::
+## Snippets
-
-For LocalStack versions before 3.0.0
-Under test>variables, add:
-LOCALSTACK_HOSTNAME: localhost.localstack.cloud
-HOSTNAME_EXTERNAL: localhost.localstack.cloud.
-
+### Start up LocalStack
-#### Service
+LocalStack requires a [CI Auth Token](https://app.localstack.cloud/workspace/auth-tokens), which you must add to the repository's environment variables as `LOCALSTACK_AUTH_TOKEN`.
+Go to your project's **Settings > CI/CD** and expand the **Variables** section.
+Select the **Add Variable** button and fill in the necessary details with `LOCALSTACK_AUTH_TOKEN` as the key and your CI Auth Token as the value.
+After you create the variable, you can use it in the `.gitlab-ci.yml` file.
-```yaml showshowLineNumbers
-...
-variables:
- DOCKER_SOCK: tcp://docker:2375
- DOCKER_HOST: tcp://docker:2375
- DOCKER_TLS_CERTDIR: ""
-...
-services:
- - name: localstack/localstack:latest
- alias: localstack
- - name: docker:dind
- alias: docker
- command: ["--tls=false"]
-...
-```
+However, variables set in the GitLab UI are not automatically passed down to service containers.
+You need to assign them as variables in the UI, and then re-assign them in your `.gitlab-ci.yml`.
#### Container
+In this setup, `lstk` owns the emulator's lifecycle: `DOCKER_HOST` points it at the `dind` daemon, and `lstk start` runs the emulator container there.
+
```yaml showshowLineNumbers
-image: docker:latest
+image: node:22
stages:
- job
@@ -55,11 +41,10 @@ stages:
job:
stage: job
variables:
- ...
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
- AWS_ENDPOINT_URL: "http://localhost.localstack.cloud:4566"
- ...
+ LOCALSTACK_AUTH_TOKEN: $LOCALSTACK_AUTH_TOKEN
+ LOCALSTACK_HOST: localhost.localstack.cloud:4566
services:
- name: docker:dind
@@ -67,57 +52,95 @@ job:
command: ["--tls=false"]
before_script:
- - apk update
- - apk add gcc musl-dev linux-headers py3-pip python3 python3-dev
- - python3 -m pip install localstack awscli
- script:
- - docker pull localstack/localstack:latest
+ - npm install -g @localstack/lstk
+ - apt-get update && apt-get install -y awscli
- dind_ip="$(getent hosts docker | cut -d' ' -f1)"
- - echo "${dind_ip} localhost.localstack.cloud " >> /etc/hosts
- - DOCKER_HOST="tcp://${dind_ip}:2375" localstack start -d
+ - echo "${dind_ip} localhost.localstack.cloud" >> /etc/hosts
+ - lstk setup aws
+ script:
+ - lstk start
+ - lstk aws s3 mb s3://test-bucket
+ - lstk aws s3 ls
```
-### Configure a CI Auth Token
+`lstk start` pulls the image, validates your license, and returns only once the emulator is ready, so no separate wait step is needed.
+Because the emulator runs on the `dind` daemon, its ports are published on the `docker` service rather than on the job container.
+The `/etc/hosts` entry and `LOCALSTACK_HOST` are what let `lstk` and your tests reach it at `localhost.localstack.cloud:4566`; without them `lstk` falls back to `127.0.0.1`, where nothing is listening.
-You can easily enable LocalStack for AWS by using the `localstack/localstack-pro` image and adding your [CI Auth Token](https://app.localstack.cloud/workspace/auth-tokens) to the repository's environment variables as `LOCALSTACK_AUTH_TOKEN`.
-Go to your project's **Settings > CI/CD** and expand the **Variables** section.
-Select the **Add Variable** button and fill in the necessary details with `LOCALSTACK_AUTH_TOKEN` as the key and your CI Auth Token as the value.
-After you create the variable, you can use it in the `.gitlab-ci.yml` file.
+:::note
+`lstk` bind-mounts the Docker socket into the emulator, and sets the emulator's own `DOCKER_HOST`, only when it reaches the daemon over a Unix socket.
+A TCP `dind` daemon has no socket to mount, so services that spawn their own containers (Lambda, ECS, EKS) need the daemon address passed in explicitly.
+`lstk start` forwards `LOCALSTACK_`-prefixed variables to the emulator, which strips the prefix, so set `LOCALSTACK_DOCKER_HOST` to the `dind` daemon as seen from inside the `dind` network (its bridge gateway, usually `tcp://172.17.0.1:2375`).
+:::
-However, variables set in the GitLab UI are not automatically passed down to service containers.
-You need to assign them as variables in the UI, and then re-assign them in your `.gitlab-ci.yml`.
+#### Service
+
+Alternatively, run LocalStack as a GitLab service container and use `lstk` purely as a client, pointing it at the service with `LSTK_ENDPOINT_URL`.
+GitLab passes the job's `variables` to service containers too, so the emulator picks up both the auth token and the Docker connection directly, with no prefixing required.
```yaml showshowLineNumbers
-...
-variables:
- LOCALSTACK_AUTH_TOKEN: $LOCALSTACK_AUTH_TOKEN
-...
-services:
- - name: localstack/localstack-pro:latest
- alias: localstack
-...
+image: node:22
+
+stages:
+ - job
+
+job:
+ stage: job
+ variables:
+ DOCKER_SOCK: tcp://docker:2375
+ DOCKER_HOST: tcp://docker:2375
+ DOCKER_TLS_CERTDIR: ""
+ LOCALSTACK_AUTH_TOKEN: $LOCALSTACK_AUTH_TOKEN
+ LSTK_ENDPOINT_URL: http://localstack:4566
+
+ services:
+ - name: localstack/localstack-pro:latest
+ alias: localstack
+ - name: docker:dind
+ alias: docker
+ command: ["--tls=false"]
+
+ before_script:
+ - npm install -g @localstack/lstk
+ - apt-get update && apt-get install -y awscli curl
+ - |
+ for _ in $(seq 1 60); do
+ curl -sf "${LSTK_ENDPOINT_URL}/_localstack/health" > /dev/null && break
+ sleep 2
+ done
+ script:
+ - lstk aws s3 mb s3://test-bucket
+ - lstk aws s3 ls
```
-You can check the logs of the LocalStack container to see if the activation was successful.
-If the CI Auth Token activation fails, LocalStack container will exit with an error code.
+GitLab starts service containers before the job's first command, but does not wait for them to become ready, hence the health poll.
-### Dump Localstack logs
+### Dump LocalStack logs
```yaml showshowLineNumbers
...
job:
- variables:
- LOCALSTACK_HOST: :
script:
- - localstack logs | tee localstack.log
-...
+ - set +e
+ - ; status=$?
+ - lstk logs --verbose | tee localstack.log
+ - exit $status
+ artifacts:
+ when: always
+ paths:
+ - localstack.log
+...
```
-In case of the service setup `LOCALSTACK_HOST` will be `localstack:4566`.
+Collect the logs as the last `script` step rather than in `after_script`, where the emulator container is no longer reachable.
+Capturing the test command's exit code keeps the job's result intact while still writing the logs after a failing test, which is when they matter most.
+
+In the [Service](#service) setup, `lstk logs` is not available, because `lstk` does not manage the service container.
+Set `CI_DEBUG_SERVICES: "true"` to have GitLab stream the service container's logs into the job log instead.
-### Store Localstack state
+### Store LocalStack state
-You can preserve your AWS infrastructure with Localstack in various ways.
+You can preserve your AWS infrastructure with LocalStack in various ways.
#### Artifact
@@ -125,18 +148,18 @@ You can preserve your AWS infrastructure with Localstack in various ways.
...
job:
before_script:
- - (test -f ./ls-state-pod.zip && localstack state import ./ls-state-pod.zip) || true
+ - (test -f ./ls-state.snapshot && lstk load ./ls-state.snapshot --merge=overwrite) || true
script:
...
- - localstack state export ./ls-state-pod.zip
+ - lstk save ./ls-state.snapshot
...
artifacts:
paths:
- - $CI_PROJECT_DIR/ls-state-pod.zip
+ - $CI_PROJECT_DIR/ls-state.snapshot
...
```
-More info about Localstack's state export and import [here](/aws/developer-tools/snapshots/saving-snapshots-locally/).
+More info about LocalStack's snapshots [here](/aws/developer-tools/snapshots/saving-snapshots-locally/).
#### Cache
@@ -144,22 +167,22 @@ More info about Localstack's state export and import [here](/aws/developer-tools
...
job:
before_script:
- - (test -f ./ls-state-pod.zip && localstack state import ./ls-state-pod.zip) || true
+ - (test -f ./ls-state.snapshot && lstk load ./ls-state.snapshot --merge=overwrite) || true
script:
...
- - localstack state export ./ls-state-pod.zip
+ - lstk save ./ls-state.snapshot
...
cache:
key:
untracked: true
files:
- - $CI_PROJECT_DIR/ls-state-pod.zip
+ - $CI_PROJECT_DIR/ls-state.snapshot
paths:
- - $CI_PROJECT_DIR/ls-state-pod.zip
+ - $CI_PROJECT_DIR/ls-state.snapshot
...
```
-Additional information about state export and import [here](/aws/developer-tools/snapshots/saving-snapshots-locally/).
+Additional information about snapshots [here](/aws/developer-tools/snapshots/saving-snapshots-locally/).
#### Cloud Pod
@@ -167,58 +190,19 @@ Additional information about state export and import [here](/aws/developer-tools
...
job:
before_script:
- - localstack pod load || true
+ - lstk load pod: || true
script:
...
- - localstack pod save
-...
-```
-
-Find more information about cloud pods [here](/aws/developer-tools/snapshots/cloud-pods).
-
-#### Ephemeral Instance (Preview)
-
-```yaml showshowLineNumbers
-...
-variables:
- LOCALSTACK_AUTH_TOKEN: $LOCALSTACK_AUTH_TOKEN
-...
-setup-job:
- stage: build
- before_script:
- - |
- response=$(curl -X POST -d '{"auto_load_pod": "false"}' \
- -H 'ls-api-key: $LOCALSTACK_API_KEY' \
- -H 'authorization: token $LOCALSTACK_API_KEY' \
- -H 'content-type: application/json' \
- https://api.localstack.cloud/v1/previews/my-gitlab-state)
-
- if [ "$endpointUrl" = "null" ] || [ "$endpointUrl" = "" ]; then
- echo "Unable to create preview environment. API response: $response"
- exit 1
- fi
- echo "Created preview environment with endpoint URL: $endpointUrl"
-
- echo "export AWS_ENDPOINT_URL=$endpointUrl"
- echo "$AWS_ENDPOINT_URL" >> ls-endpoint.env
- ...
- artifacts:
- reports:
- dotenv: ls-endpoint.env
-
-test-job:
- stage: test
- script:
- - echo "$AWS_ENDPOINT_URL" # Output is the address of the ephemeral instance
+ - lstk save pod:
...
```
-Find out more about ephemeral instances [here](/aws/developer-tools/cloud-sandbox/ephemeral-instances).
+Find more information about Cloud Pods [here](/aws/developer-tools/snapshots/cloud-pods).
## Current Limitations
-- Localstack must be able to reach a docker socket to provision containers for certain services, ie Lambda, EKS, ECS...etc
-- the runner must be able to resolve the Localstack domain (by default _localhost.localstack.cloud_), see the sample pipelines for a possible solution
-- to be able to separate steps into their own jobs one must preserve Localstack's state, since Gitlab is not preserving job related containers/services during the pipelines
-- to start up Localstack in Gitlab CI Docker tools are necessary
-- when Localstack run as a container, it's not accessible during the `after_script` phase
+- LocalStack must be able to reach a Docker socket to provision containers for certain services, such as Lambda, EKS, and ECS.
+- The runner must be able to resolve the LocalStack domain (by default _localhost.localstack.cloud_); see the sample pipelines for a possible solution.
+- To separate steps into their own jobs, you must preserve LocalStack's state, since GitLab does not preserve job-related containers or services across a pipeline.
+- Docker tooling is necessary to start up LocalStack in GitLab CI.
+- When LocalStack runs as a container, it is not accessible during the `after_script` phase.
diff --git a/src/content/docs/aws/ci-pipelines/index.md b/src/content/docs/aws/ci-pipelines/index.md
deleted file mode 100644
index 49b8ee068..000000000
--- a/src/content/docs/aws/ci-pipelines/index.md
+++ /dev/null
@@ -1,52 +0,0 @@
----
-title: Overview
-description: Use LocalStack in your CI environment to run tests against your AWS infrastructure in a high-fidelity cloud emulator.
-template: doc
-sidebar:
- order: 1
----
-
-LocalStack makes it easy to integrate cloud-native testing into your CI pipelines, without the complexity of managing real AWS environments. Running fully local AWS emulation inside your CI jobs lets you automate application testing, catch issues earlier, and ship with confidence.
-
-LocalStack supports:
-
-- Native integration with platforms like CircleCI
-- A generic CI driver for other CI/CD systems
-- Advanced features like Cloud Pods to track performance and test coverage
-
-With LocalStack in your CI pipeline, you can eliminate slow and costly staging environments while ensuring realistic, high-fidelity cloud testing before deploying to production.
-
-## Hypothetical CI workflow
-
-Let's assume that your team has an automated CI workflow into which you want to integrate end-to-end cloud testing with LocalStack.
-As an example, consider the following pipeline, which represents part of a simple CI workflow:
-
-
-
-The CI build is triggered by pushing code to a version control repository, like GitHub.
-The CI runner starts LocalStack and executes the test suite.
-You can also use the same Infrastructure-as-Code (IaC) configuration that you use to set up AWS in your production environment to set up LocalStack in the CI environment.
-You can also pre-seed state into the local AWS services (e.g., DynamoDB entries or S3 files) provided by LocalStack in your CI environment via [Cloud Pods](/aws/developer-tools/snapshots/cloud-pods).
-
-After a successful test run, you can execute the more expensive AWS CodeBuild pipeline for deploying your application.
-You can enrich the test reports created by your testing framework with traces and analytics generated inside LocalStack.
-
-## CI images
-
-LocalStack CI images require a [CI Auth Token](https://app.localstack.cloud/workspace/auth-tokens) for deployment within your CI environment.
-
-We exclusively support the [`localstack/localstack` image in Docker Hub](https://hub.docker.com/r/localstack/localstack) for all CI implementations. Detailed configuration and image specifications are available on our [Docker images](https://docs.localstack.cloud/references/docker-images/) documentation.
-
-:::note
-**Auth Token Requirement**: Using LocalStack in a CI environment requires a valid Auth Token. Ensure your environment variables are configured to include your token to avoid authentication failures during image pull or container initialization.
-:::
-
-LocalStack Docker images can be used in your CI environment by adding an [Auth Token](https://docs.localstack.cloud/aws/getting-started/auth-token/).
-
-The LocalStack Docker image is available on [Docker Hub](https://hub.docker.com/r/localstack/localstack/tags), and here is our [Docker images documentation](https://docs.localstack.cloud/references/docker-images/).
-
-
-## CI integrations
-
-The steps required for the integration differ slightly depending on your preferred CI provider.
-Please refer to the relevant documentation below to configure LocalStack for your CI pipelines.
diff --git a/src/content/docs/aws/ci-pipelines/index.mdx b/src/content/docs/aws/ci-pipelines/index.mdx
new file mode 100644
index 000000000..ace718940
--- /dev/null
+++ b/src/content/docs/aws/ci-pipelines/index.mdx
@@ -0,0 +1,55 @@
+---
+title: Overview
+description: Use LocalStack in your CI environment to run tests against your AWS infrastructure in a high-fidelity cloud emulator.
+template: doc
+sidebar:
+ order: 1
+---
+
+import SectionCards from '../../../../components/SectionCards.astro';
+
+Running integration tests against real AWS in CI means maintaining cloud accounts, waiting on slow provisioning, and sharing a staging environment with every other pipeline.
+LocalStack replaces all of that with an emulator that runs inside the CI job itself.
+Deploy with the same Infrastructure as Code you already use in production, run your test suite against emulated AWS APIs, and discard the environment when the job ends.
+Every run gets a fresh emulator instance, and no test ever requires a real AWS account.
+
+## CI workflow overview
+
+The following diagram illustrates a typical CI workflow, using LocalStack instead of the AWS cloud:
+
+
+
+A CI build is triggered when you push source code to your version control repository (such as GitHub).
+The CI runner checks out the source code, then runs a sequence of build and test steps.
+Where those tests depend on AWS services, they run against the LocalStack emulator rather than the real AWS cloud.
+You create the resources they need with standard tools such as Terraform, or load them from a [Cloud Pod](/aws/developer-tools/snapshots/cloud-pods/) to avoid redeploying your infrastructure on every run.
+
+If the tests pass, your CD pipeline takes over and deploys the application to real AWS infrastructure.
+A deployment therefore only ever starts from a build that has already been validated against emulated AWS, which increases your confidence in the code you ship.
+
+## CI integrations
+
+The steps required to run LocalStack in CI are largely the same, no matter which CI provider you use (such as GitHub Actions, GitLab CI, or CircleCI):
+
+1. Expose a CI Auth Token
+2. Install the `lstk` CLI and related tools
+3. Start the emulator
+4. Seed the emulator with the resources you need
+5. Run your tests
+6. Collect the output logs
+
+Start with the [CI Best Practices](/aws/ci-pipelines/best-practices/) page for the commands behind each step, then select your CI provider below for its own syntax and features.
+
+
diff --git a/src/content/docs/aws/ci-pipelines/travis-ci.md b/src/content/docs/aws/ci-pipelines/travis-ci.md
index 05905869c..ac1567e54 100644
--- a/src/content/docs/aws/ci-pipelines/travis-ci.md
+++ b/src/content/docs/aws/ci-pipelines/travis-ci.md
@@ -3,69 +3,55 @@ title: Travis CI
description: Use LocalStack in Travis CI.
template: doc
sidebar:
- order: 7
+ order: 8
---
-This guide shows how to start and use LocalStack in your Travis CI jobs.
+This guide shows how to start and use LocalStack in your Travis CI jobs, managed with the [`lstk` CLI](/aws/developer-tools/running-localstack/lstk/).
+
+## Configuring a CI Auth Token
+
+`lstk` validates your LocalStack license before it starts the emulator, so a [CI Auth Token](https://app.localstack.cloud/workspace/auth-tokens) is required rather than a personal Developer Auth Token.
+
+To configure this in Travis CI, go to the project settings (`More options` → `Settings`), scroll down to the `Environment Variables` section, and add your CI Auth Token as `LOCALSTACK_AUTH_TOKEN`.
+Travis CI exposes the variable to the build, and `lstk` picks it up from the environment and passes it to the emulator container.
+Keep `Display value in build log` switched off so the token is not printed.
## Setting up the Travis CI job
When you want to integrate LocalStack into your job configuration, you just have to execute the following steps:
-- Install the LocalStack CLI (and maybe also `awslocal`).
-- Make sure your LocalStack docker image is up-to-date by pulling the latest version.
-- Use the LocalStack CLI to start LocalStack.
- Make sure to use the `-d` flag to start the LocalStack docker container in detached mode.
-- Wait for the container to report that it is up and running.
+- Install `lstk`, along with the AWS CLI that `lstk aws` proxies.
+- Generate the `localstack` AWS profile with `lstk setup aws`.
+- Use `lstk` to start LocalStack.
+
+There is no need to pull the image or wait for the container: `lstk start` pulls the image if needed and returns only once the emulator is ready.
The following example Travis CI job config (`.travis.yaml`) executes these steps, creates a new S3 bucket, and prints a nice message in the end:
```yaml showshowLineNumbers
-language: python
+language: node_js
+
+node_js:
+ - "22"
services:
- docker
-python:
- - "3.8"
-
before_install:
- # Install the LocalStack CLI and awslocal
- - python -m pip install localstack awscli-local[ver1]
- # Make sure to pull the latest version of the image
- - docker pull localstack/localstack
- # Start LocalStack in the background
- - localstack start -d
- # Wait 30 seconds for the LocalStack container to become ready before timing out
- - echo "Waiting for LocalStack startup..."
- - localstack wait -t 30
- - echo "Startup complete"
+ # Install lstk
+ - npm install -g @localstack/lstk
+ # Install the AWS CLI, which `lstk aws` runs under the hood
+ - curl -sSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o awscliv2.zip
+ - unzip -q awscliv2.zip && sudo ./aws/install
+ # Write the localstack AWS profile, so lstk does not warn that it's missing
+ - lstk setup aws
+ # Start LocalStack; LOCALSTACK_AUTH_TOKEN comes from the project's environment variables
+ - lstk start
script:
# Test LocalStack by creating a new S3 bucket (and verify that it has been created by listing all buckets)
- - awslocal s3 mb s3://test
- - awslocal s3 ls
+ - lstk aws s3 mb s3://test
+ - lstk aws s3 ls
- echo "Execute your tests here :)"
```
-## Configuring a CI Auth Token
-
-You can easily enable LocalStack for AWS by using the `localstack/localstack-pro` image and adding your [CI Auth Token](https://app.localstack.cloud/workspace/auth-tokens) to the project's environment variables as `LOCALSTACK_AUTH_TOKEN`.
-The LocalStack CLI will automatically detect it and activate the Pro features.
-
-To configure this in Travis CI, go to the project settings (`More options` → `Settings`), scroll down to the `Environment Variables` section, and add your CI Auth Token as `LOCALSTACK_AUTH_TOKEN`.
-
-Here is an example workflow:
-
-```yaml showshowLineNumbers
-before_install:
- # Install the LocalStack CLI and awslocal
- - python -m pip install localstack awscli-local[ver1]
- # Make sure to pull the latest version of the image
- - docker pull localstack/localstack-pro
- # Start LocalStack in the background
- - localstack start -d
- # Wait 30 seconds for the LocalStack container to become ready before timing out
- - echo "Waiting for LocalStack startup..."
- - localstack wait -t 30
- - echo "Startup complete"
-```
\ No newline at end of file
+Travis CI images vary by language and distribution, so drop either install step if your image already provides the tool.