LocalStack Core

2026.3.0 · active · verified Sat Apr 11

LocalStack Core is the foundational Python library and runtime for LocalStack, a robust cloud service emulator that allows developers to run AWS applications and Lambdas entirely on their local machine or in CI environments without connecting to a remote cloud provider. The library underpins the LocalStack CLI and Docker container, providing the core emulation capabilities. As of the 2026.03.0 release, LocalStack has adopted calendar versioning (YYYY.MM.patch) and follows a monthly release cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to define a simple LocalStack extension using the `localstack-core` library's extension API. LocalStack extensions are Python classes that implement specific lifecycle hooks. For general interaction with LocalStack-emulated AWS services from Python, `boto3` is used and configured to point to LocalStack's local endpoints, typically at `http://localhost:4566`. Ensure Docker is running and LocalStack is started (e.g., via `localstack start`) before attempting to interact with emulated AWS services.

import logging
from localstack.extensions.api import Extension

LOG = logging.getLogger(__name__)

class ReadyAnnouncerExtension(Extension):
    name = "my_ready_announcer"

    def on_platform_ready(self):
        LOG.info("My custom extension is loaded and LocalStack is ready!")

# To run this, you would typically save it as a Python file (e.g., my_extension.py)
# and install it as a LocalStack extension, often via the LocalStack CLI:
# 1. Ensure LocalStack CLI is installed: pip install localstack
# 2. Start LocalStack (requires Docker): localstack start
# 3. Install the extension using its entry point configuration (e.g., in setup.py/cfg)
#    or directly from a file/git repo using `localstack extensions install`.
#    For demonstration, if packaged:
#    localstack extensions install my-ready-announcer
#    (This example shows the Python code for an extension, not how to run a standalone script with localstack-core)

# A more direct, though less common, 'quickstart' for *using* LocalStack from Python
# would involve the AWS SDK (boto3) configured to talk to LocalStack endpoints.
# This is typically done with `awslocal` or direct endpoint configuration.
# Example for boto3 (requires LocalStack running):
# import boto3
# import os
#
# os.environ['AWS_ACCESS_KEY_ID'] = 'test'
# os.environ['AWS_SECRET_ACCESS_KEY'] = 'test'
# os.environ['AWS_DEFAULT_REGION'] = 'us-east-1'
#
# s3_client = boto3.client('s3', endpoint_url='http://localhost:4566')
# try:
#     response = s3_client.list_buckets()
#     print(f"S3 Buckets (LocalStack): {response['Buckets']}")
# except Exception as e:
#     print(f"Error connecting to LocalStack S3: {e}")

view raw JSON →