The core library and runtime of LocalStack - a comprehensive AWS cloud emulator for local development and testing.
—
LocalStack provides a comprehensive command-line interface for managing the LocalStack runtime, configuration, services, and package management. All commands are accessed through the main localstack CLI entry point.
Core commands for starting, stopping, and managing the LocalStack runtime.
def main() -> None:
"""
Main CLI entry point. Sets LOCALSTACK_CLI=1 environment variable
and processes --profile argument before configuration loading.
Location: localstack.cli.main.main()
Entry point: /bin/localstack
"""Start LocalStack runtime with extensive configuration options.
localstack start [OPTIONS]
# Core options:
--docker # Start in Docker container (default)
--host # Start directly on host system
--no-banner # Disable LocalStack startup banner
-d, --detached # Start in background mode
# Docker configuration:
--network NETWORK # Use custom Docker network
-e, --env KEY=VALUE # Set environment variables
-p, --publish PORT # Port mappings (host:container)
-v, --volume PATH # Volume mounts (host:container)
--host-dns # Expose DNS server to host system
# Stack selection:
-s, --stack STACK # Use specific stack (e.g., localstack:4.5, snowflake)Usage examples:
# Basic start in Docker
localstack start
# Start with custom environment and ports
localstack start -e DEBUG=1 -e SERVICES=s3,lambda -p 4566:4566
# Start with custom network and volumes
localstack start --network my-network -v /tmp/localstack:/var/lib/localstack
# Start in detached mode with specific stack
localstack start -d -s localstack:4.5Stop the LocalStack runtime.
localstack stop
# Stops container named by MAIN_CONTAINER_NAME (default: localstack-main)Restart LocalStack runtime within the container without stopping the container itself.
localstack restartDisplay and follow LocalStack logs.
localstack logs [OPTIONS]
-f, --follow # Follow log output (like tail -f)
-n, --tail N # Show last N lines of logsUsage examples:
# Show recent logs
localstack logs -n 100
# Follow logs in real-time
localstack logs -fWait for LocalStack to be ready and healthy.
localstack wait [OPTIONS]
-t, --timeout N # Timeout in seconds (default: 60)Get an interactive shell inside the LocalStack container.
localstack ssh
# Opens shell in running LocalStack container for debuggingCommands for checking LocalStack and service status.
Query LocalStack operational status.
localstack status [SUBCOMMAND]
# Defaults to 'docker' subcommand if no subcommand specifiedCheck Docker container and runtime status.
localstack status docker [OPTIONS]
-f, --format FORMAT # Output format (table, plain, dict, json)Check health status of individual AWS services.
localstack status services [OPTIONS]
-f, --format FORMAT # Output format (table, plain, dict, json)Response format example:
{
"services": {
"s3": "running",
"lambda": "running",
"dynamodb": "available",
"sqs": "starting"
}
}Commands for viewing and validating LocalStack configuration.
Display current LocalStack configuration with multiple output formats.
localstack config show [OPTIONS]
-f, --format FORMAT # Output format: table, plain, dict, jsonOutput includes all environment variables, computed paths, and service settings.
Validate docker-compose configuration files.
localstack config validate [OPTIONS]
-f, --file FILE # Path to compose file (default: docker-compose.yml)Commands for updating LocalStack components and images.
Update both CLI and Docker images to latest versions.
localstack update allUpdate LocalStack CLI package via pip.
localstack update localstack-cli
# Equivalent to: pip install --upgrade localstack-corePull latest LocalStack Docker images.
localstack update docker-images
# Updates: localstack/localstack, localstack/localstack-pro, etc.LocalStack Package Manager for installing additional components and services.
List available packages in the LocalStack package repository.
localstack lpm list [OPTIONS]
-v, --verbose # Show detailed package information and versionsInstall one or more packages with configuration options.
localstack lpm install PACKAGE [PACKAGE...] [OPTIONS]
--parallel N # Number of parallel installers (default: 1)
--version VERSION # Install specific package version
--target TARGET # Installation target directoryUsage examples:
# Install single package
localstack lpm install dynamodb-local
# Install multiple packages in parallel
localstack lpm install --parallel 3 opensearch elasticsearch redis
# Install specific version
localstack lpm install --version 2.0.1 kinesis-mockAdditional utility and integration commands.
Generate shell completion scripts for bash, zsh, and fish.
localstack completion SHELL
# Supported shells: bash, zsh, fishSetup examples:
# Bash completion
localstack completion bash > ~/.localstack-completion.bash
echo 'source ~/.localstack-completion.bash' >> ~/.bashrc
# Zsh completion
localstack completion zsh > ~/.localstack-completion.zsh
echo 'source ~/.localstack-completion.zsh' >> ~/.zshrc
# Fish completion
localstack completion fish > ~/.config/fish/completions/localstack.fishDynamic command loading via the plugin system.
class LocalstackCliPlugin:
"""
Base class for CLI plugins that can add custom commands.
Namespace: localstack.plugins.cli
"""
namespace: str = "localstack.plugins.cli"
def attach(self, cli) -> None:
"""
Attach custom commands to the LocalStack CLI.
Args:
cli: LocalStack CLI instance
"""
def load_cli_plugins(cli) -> None:
"""
Discover and load all CLI plugins from the namespace.
Called automatically during CLI initialization.
"""Plugin commands are automatically discovered and loaded from the localstack.plugins.cli namespace, allowing extensions to add custom functionality to the CLI.
Key environment variables that affect CLI behavior:
# CLI behavior
LOCALSTACK_CLI = "1" # Set automatically when using CLI
CONFIG_PROFILE = "profile" # Active configuration profile
# Container management
MAIN_CONTAINER_NAME = "localstack-main" # Default container name
MAIN_DOCKER_NETWORK = "bridge" # Docker network for container
# Debugging and logging
DEBUG = "1" # Enable debug mode
LS_LOG = "info" # Logging level (trace, debug, info, warn, error)Standard exit codes returned by CLI commands:
0 - Success1 - General error (configuration, runtime error)2 - Command line usage error3 - Service startup failure130 - Interrupted by user (Ctrl+C)CLI respects configuration from multiple sources in order of precedence:
~/.localstack/profiles/<profile_name>)~/.localstack/config)Profile loading is handled automatically when --profile argument is provided and occurs before general configuration loading.
Install with Tessl CLI
npx tessl i tessl/pypi-localstack-core