localstack – Local AWS Cloud Stack

superior_hosting_service

localstack

A fully functional local AWS cloud stack. Develop and test your cloud & Serverless apps offline!


LocalStack provides an easy-to-use test/mocking framework for developing Cloud applications.

Overview

LocalStack spins up the following core Cloud APIs on your local machine.

Note: Starting with version 0.11.0, all APIs are exposed via a single edge service, which is accessible on http://localhost:4566 by default (customizable via EDGE_PORT, see further below).

  • ACM
  • API Gateway
  • CloudFormation
  • CloudWatch
  • CloudWatch Logs
  • DynamoDB
  • DynamoDB Streams
  • EC2
  • Elasticsearch Service
  • EventBridge (CloudWatch Events)
  • Firehose
  • IAM
  • Kinesis
  • KMS
  • Lambda
  • Redshift
  • Route53
  • S3
  • SecretsManager
  • SES
  • SNS
  • SQS
  • SSM
  • StepFunctions
  • STS

In addition to the above, the Pro version of LocalStack supports additional APIs and advanced features, including:

  • Amplify
  • API Gateway V2 (WebSockets support)
  • AppConfig
  • Application AutoScaling
  • AppSync
  • Athena
  • Backup
  • Batch
  • CloudFront
  • CloudTrail
  • CodeCommit
  • Cognito
  • CostExplorer
  • DocumentDB
  • ECR/ECS/EKS
  • ElastiCache
  • ElasticBeanstalk
  • ELB/ELBv2
  • EMR
  • Glacier / S3 Select
  • Glue
  • IAM Security Policy Enforcement
  • IoT
  • Kinesis Data Analytics
  • Lambda Layers & Container Images
  • Managed Streaming for Kafka (MSK)
  • MediaStore
  • Neptune Graph DB
  • QLDB
  • RDS / Aurora Serverless
  • Route53 DNS integration
  • SageMaker
  • Timestream
  • Transfer
  • XRay
  • Advanced persistence support, Local Cloud Pods
  • Interactive UIs to manage resources
  • Test report dashboards
  • …and much, much more to come! (Check out our feature roadmap here: https://roadmap.localstack.cloud)

Requirements

  • python (Python 3.6 up to 3.8 supported)
  • pip (python package manager)
  • Docker
  • JDK (If KINESIS_PROVIDER is kinesis-mock and the system is not an amd64 system. 8+ supported)

Installing

The easiest way to install LocalStack is via pip:

pip install localstack

Note: Please do not use sudo or the root user – LocalStack should be installed and started entirely under a local non-root user. If you have problems with permissions in MacOS X Sierra, install with pip install --user localstack

Running

By default, LocalStack gets started inside a Docker container using this command:

localstack start

(Note that on MacOS you may have to run TMPDIR=/private$TMPDIR localstack start --docker if $TMPDIR contains a symbolic link that cannot be mounted by Docker.)

Note: From 2020-07-11 onwards, the default image localstack/localstack in Docker Hub refers to the “light version”, which has some large dependency files like Elasticsearch removed (and lazily downloads them, if required). (Note that the localstack/localstack-light image alias may get removed in the future). In case you need the full set of dependencies, the localstack/localstack-full image can be used instead. Please also refer to the USE_LIGHT_IMAGE configuration below.

Note: By default, LocalStack uses the image tagged latest that is cached on your machine, and will not pull the latest image automatically from Docker Hub (i.e., the image needs to be pulled manually if needed).

(Note: Although it is strongly recommended to use Docker, the infrastructure can also be spun up directly on the host machine using the --host startup flag. Note that this will require additional dependencies, and is not supported on some operating systems, including Windows.)

Using docker

You can also use docker directly and use the following command to get started with localstack

docker run --rm -it -p 4566:4566 -p 4571:4571 localstack/localstack

Note that this will pull the current nighty build from the master branch and not the latest supported version.

to run a throw-away container without any external volumes. To start a subset of services use -e "SERVICES=dynamodb,s3".

Using docker-compose

You can also use the docker-compose.yml file from the repository and use this command (currently requires docker-compose version 1.9.0+):

docker-compose up

(Note that on MacOS you may have to run TMPDIR=/private$TMPDIR docker-compose up if $TMPDIR contains a symbolic link that cannot be mounted by Docker.)

To facilitate interoperability, configuration variables can be prefixed with LOCALSTACK_ in docker. For instance, setting LOCALSTACK_SERVICES=s3 is equivalent to SERVICES=s3.

Using Helm

You can use Helm to install LocalStack in a Kubernetes cluster by running these commands (the Helm charts are maintained in this repo):

helm repo add localstack-repo https://helm.localstack.cloud

helm upgrade --install localstack localstack-repo/localstack

Configurations

You can pass the following environment variables to LocalStack.

Core Configurations

  • SERVICES: Comma-separated list of service names (APIs) to start up. Service names basically correspond to the service names of the AWS CLI (kinesislambdasqs, etc), although LocalStack only supports a subset of them. Example value: kinesis,lambda,sqs to start Kinesis, Lambda, and SQS. In addition, the following shorthand values can be specified to run a predefined ensemble of services:
    • serverless: run services often used for Serverless apps (iamlambdadynamodbapigateways3sns)
  • EDGE_BIND_HOST: Address the edge service binds to. (default: 127.0.0.1, in docker containers 0.0.0.0)
  • EDGE_PORT: Port number for the edge service, the main entry point for all API invocations (default: 4566).
  • HOSTNAME: Name of the host to expose the services internally (default: localhost). Use this to customize the framework-internal communication, e.g., if services are started in different containers using docker-compose.
  • HOSTNAME_EXTERNAL: Name of the host to expose the services externally (default: localhost). This host is used, e.g., when returning queue URLs from the SQS service to the client.
  • DEBUG: Flag to increase log level and print more verbose logs (useful for troubleshooting issues)
  • <SERVICE>_PORT_EXTERNAL: Port number to expose a specific service externally (defaults to service ports above). SQS_PORT_EXTERNAL, for example, is used when returning queue URLs from the SQS service to the client.
  • IMAGE_NAME: Specific name and tag of LocalStack Docker image to use, e.g., localstack/localstack:0.11.0 (default: localstack/localstack).
  • USE_LIGHT_IMAGE: Whether to use the light-weight Docker image (default: 1). Overwritten by IMAGE_NAME.
  • TMPDIR: Temporary folder inside the LocalStack container (default: /tmp).
  • HOST_TMP_FOLDER: Temporary folder on the host that gets mounted as $TMPDIR/localstack into the LocalStack container. Required only for Lambda volume mounts when using LAMBDA_REMOTE_DOCKER=false.
  • DATA_DIR: Local directory for saving persistent data (currently only supported for these services: Kinesis, DynamoDB, Elasticsearch, S3, Secretsmanager, SSM, SQS, SNS). Set it to /tmp/localstack/data to enable persistence (/tmp/localstack is mounted into the Docker container), leave blank to disable persistence (default).
  • PERSISTENCE_SINGLE_FILE: Specify if persistence files should be combined. (default: true).
  • <SERVICE>_BACKEND: Custom endpoint URL to use for a specific service, where <SERVICE> is the uppercase service name (currently works for: APIGATEWAYCLOUDFORMATIONDYNAMODBELASTICSEARCHKINESISS3SNSSQS). This allows to easily integrate third-party services into LocalStack. You can take a look at an elasticsearch example here.
  • FORCE_NONINTERACTIVE: when running with Docker, disables the --interactive and --tty flags. Useful when running headless.
  • DOCKER_FLAGS: Allows to pass custom flags (e.g., volume mounts) to “docker run” when running LocalStack in Docker.
  • DOCKER_CMD: Shell command used to run Docker containers, e.g., set to "sudo docker" to run as sudo (default: docker).
  • MAIN_CONTAINER_NAME: Specify the main docker container name (default: localstack_main).
  • INIT_SCRIPTS_PATH: Specify the path to the initializing files with extensions .sh that are found default in /docker-entrypoint-initaws.d.
  • LS_LOG: Specify the log level(‘trace’, ‘debug’, ‘info’, ‘warn’, ‘error’, ‘warning’) currently overrides the DEBUG configuration. Enable LS_LOG=trace to print detailed request/response messages.

An example passing the above environment variables to LocalStack to start Kinesis, Lambda, Dynamodb and SQS:

SERVICES=kinesis,lambda,sqs,dynamodb DEBUG=1 localstack start

Lambda Configurations

  • LAMBDA_EXECUTOR: Method to use for executing Lambda functions. Possible values are:
    • local: run Lambda functions in a temporary directory on the local machine
    • docker: run each function invocation in a separate Docker container
    • docker-reuse: create one Docker container per function and reuse it across invocations
    For docker and docker-reuse, if LocalStack itself is started inside Docker, then the docker command needs to be available inside the container (usually requires to run the container in privileged mode). Default is docker, fallback to local if Docker is not available.
  • LAMBDA_REMOTE_DOCKER determines whether Lambda code is copied or mounted into containers. Possible values are:
    • true (default): your Lambda function definitions will be passed to the container by copying the zip file (potentially slower). It allows for remote execution, where the host and the client are not on the same machine.
    • false: your Lambda function definitions will be passed to the container by mounting a volume (potentially faster). This requires to have the Docker client and the Docker host on the same machine. Also, HOST_TMP_FOLDER must be set properly, and a volume mount like ${HOST_TMP_FOLDER}:/tmp/localstack needs to be configured if you’re using docker-compose.
  • BUCKET_MARKER_LOCAL: Optional bucket name for running lambdas locally.
  • LAMBDA_DOCKER_NETWORK: Optional Docker network for the container running your lambda function.
  • LAMBDA_DOCKER_DNS: Optional DNS server for the container running your lambda function.
  • LAMBDA_DOCKER_FLAGS: Additional flags passed to Lambda Docker run/create commands (e.g., useful for specifying custom volume mounts). Does only support environment, volume and port flags (with -e KEY=VALUE-v host:container-p host:container respectively)
  • LAMBDA_CONTAINER_REGISTRY Use an alternative docker registry to pull lambda execution containers (default: lambci/lambda).
  • LAMBDA_REMOVE_CONTAINERS: Whether to remove containers after Lambdas finished executing (default: true).
  • LAMBDA_FALLBACK_URL: Fallback URL to use when a non-existing Lambda is invoked. Either records invocations in DynamoDB (value dynamodb://<table_name>) or forwards invocations as a POST request (value http(s)://...).
  • LAMBDA_FORWARD_URL: URL used to forward all Lambda invocations (useful to run Lambdas via an external service).
  • LAMBDA_JAVA_OPTS: Allow passing custom JVM options (e.g., -Xmx512M) to Java Lambdas executed in Docker. Use _debug_port_ placeholder to configure the debug port (e.g., -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=_debug_port_).
  • HOSTNAME_FROM_LAMBDA: Endpoint host under which APIs are accessible from Lambda containers (optional). This can be useful in docker-compose stacks to use the local container hostname (e.g., HOSTNAME_FROM_LAMBDA=localstack) if neither IP address nor container name of the main container are available (e.g., in CI). Often used in combination with LAMBDA_DOCKER_NETWORK.

Service-Specific Configurations

  • KINESIS_PROVIDER: Determines which provider to use for Kinesis. Valid values are kinesalite and kinesis-mock (default).
  • KINESIS_ERROR_PROBABILITY: Decimal value between 0.0 (default) and 1.0 to randomly inject ProvisionedThroughputExceededException errors into Kinesis API responses.
  • KINESIS_SHARD_LIMIT: Integer value (default: 100) or Infinity (to disable), causing the Kinesis API to start throwing exceptions to mimick the default shard limit.
  • KINESIS_LATENCY: Integer value of milliseconds (default: 500) or 0 (to disable), causing the Kinesis API to delay returning a response in order to mimick latency from a live AWS call.
  • KINESIS_INITIALIZE_STREAMS: A comma-delimited string of stream names and its corresponding shard count to initialize during startup. For example: “my-first-stream:1,my-other-stream:2,my-last-stream:1”. Only works with the kinesis-mock KINESIS_PROVIDER.
  • DYNAMODB_ERROR_PROBABILITY: Decimal value between 0.0 (default) and 1.0 to randomly inject ProvisionedThroughputExceededException errors into DynamoDB API responses.
  • DYNAMODB_HEAP_SIZE: Sets the JAVA EE maximum memory size for dynamodb values are (integer)m for MB, (integer)G for GB default(256m), full table scans require more memory
  • STEPFUNCTIONS_LAMBDA_ENDPOINT: URL to use as the Lambda service endpoint in Step Functions. By default this is the LocalStack Lambda endpoint. Use default to select the original AWS Lambda endpoint.

Security Configurations

Please be aware that the following configurations may have severe security implications!

  • DISABLE_CORS_CHECKS: Whether to disable all CSRF mitigations (default: 0).
  • DISABLE_CUSTOM_CORS_S3: Whether to disable CORS override by S3 (default: 0).
  • DISABLE_CUSTOM_CORS_APIGATEWAY: Whether to disable CORS override by apigateway (default: 0).
  • EXTRA_CORS_ALLOWED_ORIGINS: Comma-separated list of origins that are allowed to communicate with localstack.
  • EXTRA_CORS_ALLOWED_HEADERS: Comma-separated list of header names to be be added to Access-Control-Allow-Headers CORS header
  • EXTRA_CORS_EXPOSE_HEADERS: Comma-separated list of header names to be be added to Access-Control-Expose-Headers CORS header

Miscellaneous Configurations

  • SKIP_INFRA_DOWNLOADS: Whether to skip downloading additional infrastructure components (e.g., specific Elasticsearch versions).
  • IGNORE_ES_DOWNLOAD_ERRORS: Whether to ignore errors (e.g., network/SSL) when downloading Elasticsearch plugins.
  • OVERRIDE_IN_DOCKER: Overrides the check whether LocalStack is executed within a docker container. If set to true, LocalStack assumes it runs in a docker container. Should not be set unless necessary.
  • EDGE_FORWARD_URL: Optional target URL to forward all edge requests to (e.g., for distributed deployments).

Debugging Configurations

The following environment configurations can be useful for debugging:

  • DEVELOP: Starts a debugpy server before starting LocalStack services
  • DEVELOP_PORT: Port number for debugpy server
  • WAIT_FOR_DEBUGGER: Forces LocalStack to wait for a debugger to start the services

The following environment configurations are deprecated:

  • USE_SSL: Whether to use https://... URLs with SSL encryption (default: false). Deprecated as of version 0.11.3 – each service endpoint now supports multiplexing HTTP/HTTPS traffic over the same port.
  • DEFAULT_REGION: AWS region to use when talking to the API (needs to be activated via USE_SINGLE_REGION=1). Deprecated and inactive as of version 0.12.17 – LocalStack now has full multi-region support.
  • USE_SINGLE_REGION: Whether to use the legacy single-region mode, defined via DEFAULT_REGION.

Additionally, the following read-only environment variables are available:

  • LOCALSTACK_HOSTNAME: Name of the host where LocalStack services are available. Use this hostname as endpoint (e.g., http://${LOCALSTACK_HOSTNAME}:4566) in order to access the services from within your Lambda functions (e.g., to store an item to DynamoDB or S3 from a Lambda).

Verifying your docker-compose configuration using the command line

You can use the localstack config validate command to check for common mis-configurations.

By default it validates docker-compose.yml, the target file can be specified using the --file argument, e.g.,:

localstack config validate --file=localstack-docker-compose.yml

Dynamically updating configuration at runtime

Each of the service APIs listed above defines a backdoor API under the path /?_config_ which allows to dynamically update configuration variables defined in config.py.

You need to enable this endpoint by setting ENABLE_CONFIG_UPDATES=1.

For example, to dynamically set KINESIS_ERROR_PROBABILITY=1 at runtime, use the following command:

curl -v -d '{"variable":"KINESIS_ERROR_PROBABILITY","value":1}' 'http://localhost:4566/?_config_'

Service health checks

The service /health check endpoint on the edge port (http://localhost:4566/health by default) provides basic information about the status of each service (e.g., {"s3":"running","es":"starting"}). By default, the endpoint returns cached values that are determined during startup – the status values can be refreshed by adding the reload query parameter: http://localhost:4566/health?reload.

Initializing a fresh instance

When a container is started for the first time, it will execute files with extensions .sh that are found in /docker-entrypoint-initaws.d or an alternate path defined in INIT_SCRIPTS_PATH. Files will be executed in alphabetical order. You can easily create aws resources on localstack using awslocal (or aws) cli tool in the initialization scripts.

Using custom SSL certificates

To use your own SSL certificate instead of the randomly generated certificate, you can place a file server.test.pem into the LocalStack temporary directory ($TMPDIR/localstack, or /tmp/localstack by default). The file server.test.pem must contain the key file, as well as the certificate file content:

-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----

Using custom SSL certificates with docker-compose

Typically with docker-compose you can add into docker-compose.yml this volume to the LocalStack services :

  volumes:
    - "${PWD}/ls_tmp:/tmp/localstack"
    - "/var/run/docker.sock:/var/run/docker.sock"

The local directory /ls_tmp must contains the three files (server.test.pem, server.test.pem.crt, server.test.pem.key)

Accessing the infrastructure via CLI or code

You can point your aws CLI to use the local infrastructure, for example:

aws --endpoint-url=http://localhost:4566 kinesis list-streams
{
    "StreamNames": []
}

Use the below command to install aws CLI, if not installed already.

pip install awscli

Setting up local region and credentials to run LocalStack

aws requires the region and the credentials to be set in order to run the aws commands. Create the default configuration & the credentials. Below key will ask for the Access key id, secret Access Key, region & output format.

aws configure --profile default

# Config & credential file will be created under ~/.aws folder

NOTE: Please use test as Access key id and secret Access Key to make S3 presign url work. We have added presign url signature verification algorithm to validate the presign url and its expiration. You can configure credentials into the system environment using export command in the linux/Mac system. You also can add credentials in ~/.aws/credentials file directly.

export AWS_ACCESS_KEY_ID=test
export AWS_SECRET_ACCESS_KEY=test

NEW: Check out awslocal, a thin CLI wrapper that runs commands directly against LocalStack (no need to specify --endpoint-url anymore). Install it via pip install awscli-local, and then use it as follows:

awslocal kinesis list-streams
{
    "StreamNames": []
}

UPDATE: Use the environment variable $LOCALSTACK_HOSTNAME to determine the target host inside your Lambda function. See Configurations section for more details.

Using the official AWS CLI version 2 Docker image with Localstack Docker container

By default the container running amazon/aws-cli is isolated from 0.0.0.0:4566 on the host machine, that means that aws-cli cannot reach localstack through your shell.

To ensure that the two docker containers can communicate create a network on the docker engine:

$ ▶ docker network create localstack
0c9cb3d37b0ea1bfeb6b77ade0ce5525e33c7929d69f49c3e5ed0af457bdf123

Then modify the docker-compose.yml specifying the network to use:

networks:
  default:
    external:
      name: "localstack"

Run AWS Cli v2 docker container using this network (example):

$ ▶ docker run --network localstack --rm -it amazon/aws-cli --endpoint-url=http://localstack:4566 lambda list-functions
{
    "Functions": []
}

If you use AWS CLI v2 from a docker container often, create an alias:

$ ▶ alias laws='docker run --network localstack --rm -it amazon/aws-cli --endpoint-url=http://localstack:4566'

So you can type:

$ ▶ laws lambda list-functions
{
    "Functions": []
}

Client Libraries

Invoking API Gateway

While API Gateway endpoints on AWS use a custom DNS name to identify the API ID (e.g., https://nmafetnwf6.execute-api.us-east-1.amazonaws.com/prod/my/path), LocalStack uses the special URL path indicator .../_user_request_/... to indicate the execution of a REST API method.

The URL pattern for API Gateway executions is http://localhost:4566/restapis/<apiId>/<stage>/_user_request_/<methodPath>. The example URL above would map to the following localhost URL:

$ curl http://localhost:4566/restapis/nmafetnwf6/prod/_user_request_/my/path

Testing Backdoors and Special Features

LocalStack provides a number of small backdoors and utility features that are designed to make local testing even easier and more efficient.

  • Providing custom IDs for API Gateway REST APIs: You can specify tags={"_custom_id_":"myid123"} on creation of an API Gateway REST API, to assign it the custom ID "myid123" (can be useful to have a static API GW endpoint URL for testing).

Integrations

pytest

If you want to use LocalStack in your integration tests (e.g., pytest), simply fire up the infrastructure in your test setup method and then clean up everything in your teardown method:

from localstack.services import infra

def setup():
    infra.start_infra(asynchronous=True)

def teardown():
    infra.stop_infra()

def my_app_test():
    # here goes your test logic

See the example test file tests/integration/test_integration.py for more details.

Serverless Framework

You can use the serverless-localstack plugin to easily run Serverless applications on LocalStack. For more information, please check out the plugin repository here: https://github.com/localstack/serverless-localstack

Thundra

You can monitor and debug your AWS Lambda functions with Thundra. Currently only Java Lambdas are supported in this integration – support for other runtimes (Node.js, Python, .NET, Go) is coming soon.

Simply obtain a Thundra API key here and configure the THUNDRA_APIKEY config variable:

THUNDRA_APIKEY=<YOUR-THUNDRA-API-KEY> localstack start

After invoking your AWS Lambda function you can inspect the invocations/traces in the Thundra Console (more details in the Thundra docs here).

Terraform

You can use Terraform to provision your resources locally. Please refer to the Terraform AWS Provider docs here on how to configure the API endpoints on localhost.

Using local code with Lambda

In order to mount a local folder, ensure that LAMBDA_REMOTE_DOCKER is set to false then set the S3 bucket name to __local__ or BUCKET_MARKER_LOCAL if it is set, and the S3 key to your local path:

awslocal lambda create-function --function-name myLambda \
    --code S3Bucket="__local__",S3Key="/my/local/lambda/folder" \
    --handler index.myHandler \
    --runtime nodejs8.10 \
    --role whatever

Note: When using LAMBDA_REMOTE_DOCKER=false, make sure to properly set the HOST_TMP_FOLDER environment variable for the LocalStack container (see Configuration section above).

Integration with Java/JUnit

In order to use LocalStack with Java, the project ships with a simple JUnit runner, see sample below.

...
import cloud.localstack.LocalstackTestRunner;
import cloud.localstack.TestUtils;
import cloud.localstack.docker.annotation.LocalstackDockerProperties;

@RunWith(LocalstackTestRunner.class)
@LocalstackDockerProperties(services = { "s3", "sqs", "kinesis:77077" })
public class MyCloudAppTest {

  @Test
  public void testLocalS3API() {
    AmazonS3 s3 = TestUtils.getClientS3()
    List<Bucket> buckets = s3.listBuckets();
    ...
  }
}

For more details and a complete list of configuration parameters, please refer to the LocalStack Java Utils repository.

Troubleshooting

  • If you’re using AWS Java libraries with Kinesis, please, refer to CBOR protocol issues with the Java SDK guide how to disable CBOR protocol which is not supported by kinesalite.
  • Accessing local S3: To avoid domain name resolution issues, you need to enable path style access on your S3 SDK client. Most AWS SDKs provide a config to achieve that, e.g., for Java:
s3.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(true).build());
// There is also an option to do this if you're using any of the client builder classes:
AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard();
builder.withPathStyleAccessEnabled(true);
...
  • Mounting the temp. directory: Note that on MacOS you may have to run TMPDIR=/private$TMPDIR docker-compose up if $TMPDIR contains a symbolic link that cannot be mounted by Docker. (See details here: https://bitbucket.org/atlassian/localstack/issues/40/getting-mounts-failed-on-docker-compose-up)
  • If you’re seeing Lambda errors like Cannot find module ... when using LAMBDA_REMOTE_DOCKER=false, make sure to properly set the HOST_TMP_FOLDER environment variable and mount the temporary folder from the host into the LocalStack container.
  • If you run into file permission issues on pip install under Mac OS (e.g., Permission denied: '/Library/Python/2.7/site-packages/six.py'), then you may have to re-install pip via Homebrew (see this discussion thread). Alternatively, try installing with the --user flag: pip install --user localstack
  • If you are deploying within OpenShift, please be aware: the pod must run as root, and the user must have capabilities added to the running pod, in order to allow Elasticsearch to be run as the non-root localstack user.
  • If you are experiencing slow performance with Lambdas in Mac OS, you could either (1) try mounting local code directly into the Lambda container, or (2) disable mounting the temporary directory into the LocalStack container in docker-compose. (See also https://github.com/localstack/localstack/issues/2515)
  • The environment variable no_proxy is rewritten by LocalStack. (Internal requests will go straight via localhost, bypassing any proxy configuration).
  • For troubleshooting LocalStack start issues, you can check debug logs by running DEBUG=1 localstack start
  • In case you get errors related to node/nodejs, you may find (this issue comment: https://github.com/localstack/localstack/issues/227#issuecomment-319938530) helpful.
  • If you are using AWS Java libraries and need to disable SSL certificate checking, add -Dcom.amazonaws.sdk.disableCertChecking to the java invocation.

Developing

Requirements for developing or starting locally

To develop new features, or to start the stack locally (outside of Docker), the following additional tools are required:

  • make
  • npm (node.js package manager)
  • java/javac (Java 8 runtime environment and compiler)
  • mvn (Maven, the build system for Java)
  • moto(for testing)
  • docker-compose (for running the localstack using docker-compose)
  • mock (for unit testing)
  • pytest (for unit testing)
  • pytest-cov (to check the unit-testing coverage)

Building the Docker image

Please note that there are a few commands we need to run on the host to prepare the local environment for the Docker build – specifically, downloading some dependencies like the StepFunctions local binary. Therefore, simply running docker build . in a fresh clone of the repo may not work.

We generally recommend using this command to build the Docker image locally (works on Linux/MacOS):

make docker-build

Development Environment

If you pull the repo in order to extend/modify LocalStack, run this command to install all the dependencies:

make install

This will install the required pip dependencies in a local Python virtualenv directory .venv (your global python packages will remain untouched), as well as some node modules in ./localstack/node_modules/. Depending on your system, some pip/npm modules may require additional native libs installed.

The Makefile contains a target to conveniently run the local infrastructure for development:

make infra

Starting LocalStack using Vagrant (Centos 8)

This is similar to make docker-mount-run, but instead of docker centos VM will be started and source code will be mounted inside.

Pre-requirements
  • Vagrant
  • vagrant plugin install vagrant-vbguest
Starting Vagrant
  • make vagrant-start (be ready to provide system password)
Using Vagrant
  • vagrant ssh
  • sudo -s
  • cd /localstack
  • SERVICES=dynamodb DEBUG=1 make docker-mount-run
Stopping Vagrant
  • make vagrant-stop or vagrant halt
Deleting Vagrant VM
  • vagrant destroy

Check out the developer guide which contains a few instructions on how to get started with developing (and debugging) features for LocalStack.

Testing

The project contains a set of unit and integration tests that can be kicked off via a make target:

make test

To check the Code Coverage

Once the new feature / bug fix is done, run the unit testing and check for the coverage.

# To run the particular test file (sample)
pytest --cov=localstack tests/unit/test_common.py

# To check the coverage in the console
coverage report

# To check the coverage as html (output will be redirected to the html folder)
coverage html

Other UI Clients

Change Log

Please refer to CHANGELOG.md to see the complete list of changes for each release.

Contributing

We welcome feedback, bug reports, and pull requests!

For pull requests, please stick to the following guidelines:

  • Add tests for any new features and bug fixes. Ideally, each PR should increase the test coverage.
  • Follow the existing code style (e.g., indents). A PEP8 code linting target is included in the Makefile.
  • Put a reasonable amount of comments into the code.
  • Fork localstack on your GitHub user account, do your changes there and then create a PR against main localstack repository.
  • Separate unrelated changes into multiple pull requests.
  • 1 commit per PR: Please squash/rebase multiple commits into one single commit (to keep the history clean).

Please note that by contributing any code or documentation to this repository (by raising pull requests, or otherwise) you explicitly agree to the Contributor License Agreement.