Skip to content
Get Started for Free

CI/CD Integration

Integrating LocalStack into CI/CD environments enables automated integration testing without cloud infrastructure costs or vendor dependency. CI configurations differ from local development environments in authentication methods and startup workflows.

Key operational differences in CI/CD include:

  • Authentication: Use a dedicated CI Auth Token instead of a personal Developer token.
  • Initialization: Execute LocalStack in non-interactive mode using Docker Compose, the Docker CLI, or specialized CI actions.
  • Isolation: Initialize a fresh LocalStack instance for each job to ensure reproducible test results.
  • State Management: Utilize Cloud Pods or state export/import commands to persist infrastructure across pipeline stages.

Dedicated CI Auth Tokens are required for automated environments to ensure security and auditability.

  1. Navigate to the Auth Tokens page in the LocalStack Web Application.
  2. Generate a new CI Auth Token.
  3. Store the token as a protected secret within your CI provider (e.g., LOCALSTACK_AUTH_TOKEN).

Select the integration method compatible with your CI runner architecture.

Use the official GitHub Action to initialize LocalStack as a workflow step:

.github/workflows/integration-tests.yml
name: Integration Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Start LocalStack
uses: LocalStack/setup-localstack@v0.2.2
with:
image-tag: latest
install-awslocal: "true"
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
- name: Run tests
run: |
# Your test commands here, e.g.:
pip install awscli-local
awslocal s3 mb s3://integration-test-bucket
pytest tests/integration/

The setup-localstack action pulls the image, starts the container, and waits for LocalStack to be ready.

FeatureLocal DevelopmentCI/CD Environment
Interfacelstk or LocalStack CLIDocker Compose / docker run, or lstk --non-interactive
AuthenticationBrowser-based or stored credentialsLOCALSTACK_AUTH_TOKEN environment variable
Token TypeIndividual Developer TokenDedicated CI Token
StatePersistent by choiceEphemeral (standard) or Snapshotted (Cloud Pods)
Startup ModeInteractive (TUI) (default lstk)Non-interactive (Headless) (docker compose, docker run -d, lstk --non-interactive)

While most pipelines favor ephemeral instances for clean test cycles, certain workflows require persisting infrastructure state across jobs or runners.

  • Cloud Pods: Save or load snapshots using the setup-localstack action with the state-backend: cloud-pods configuration.
  • Snapshot Persistence Engine: Enable PERSISTENCE=1 and mount a host volume to retain data across container restarts on the same runner.
  • State Export/Import Commands: Use localstack state export and localstack state import to pass infrastructure state via CI artifacts or caching mechanisms.

You have configured LocalStack for automated environments and explored various CI/CD integration patterns. Proceed to the AI & Agent Workflows Guide to learn how to integrate LocalStack with AI coding assistants and automate infrastructure tasks.

Was this page helpful?